I have one file stored in google drive which I download using:
url = 'https://docs.google.com/spreadsheets/d/ID/edit?usp=sharing'
output = 'file.xlsx'
gdown.download(url, output, quiet=False)
My goal is to make that file downloadable in a html file through a button using Google Drive as a backend. Is there any way to do that?
Summarizing: Some user open an html file where there's a button to download some file placed in my drive.
the flask template I am thinking to use looks like:
from flask import Flask, Response
app = Flask(__name__)
@app.route("/")
def hello():
return '''
<html><body>
Hello. <a href="/getPlotCSV">Click me.</a>
</body></html>
'''
@app.route("/getPlotCSV")
def getPlotCSV():
# with open("outputs/Adjacency.csv") as fp:
# csv = fp.read()
excel = '1,2,3\n4,5,6\n'
return Response(
excel,
mimetype="xlsx",
headers={"Content-disposition":
"attachment; filename=file.xlsx"})
EDIT:
I mapped my html button with
"""<form action={url}> <input type=submit value=Go to Google/></form>
"""
but it takes me directly to the spreadsheet in google sheets. How do I assign an action to that button so that the file is downloaded locally to the user?