How do I properly open an html document in Google Drive?

Im using Google Drive API for creating and opening html file. But the problem is that the document opens with the technical content (links to css, js files, html tags ...) like this

enter image description here

How to make it so that it would open correctly, in a user-friendly form?

part of my google-api code

def file_to_drive(import_file=None):    
    service = build('drive', 'v3', credentials=creds)
    file_name = import_file
    media_body = MediaFileUpload(file_name, resumable=True, mimetype='text/html')
    body = {
        'title': file_name,
        'description': 'Uploaded By You'}
    file = service.files().create(body=body, media_body=media_body, fields='id')

1 answer

  • answered 2019-09-11 09:14 DaImTo

    The google drive API is a file store api. It allows you to upload and download files. It does not have the ability to open files. You could share a link to the file with someone that has access then when they click on the link it will open for them in the google drive web application.

    The only api able to open files for editing would be the Google docs api which gives you limited ability to open google doc files. that however would require that you covert your html file to a google docs format. Even if this was an option you would need to create your own "user friendly form" Google apis return data as json and not user friendly options thats not what APIs are for.