Have flask project i want make excel file from dataframe and download it in browser for url "test.com/excel" for example i trying this until now:
import pandas as pd
import io
import requests
@app.route('/to_excel')
def to_excel():
df = pd.DataFrame({'col1': [1, 2], 'col2': [3, 4]})
output = io.BytesIO()
writer = pd.ExcelWriter(output, engine='xlsxwriter')
df.to_excel(writer)
writer.save()
xlsx_data = output.getvalue()
does it correct and what is the next step to download excel file on client browser?