I have a Flask code with decorator @app.route(/bestApp) to fetch my data from Fetch API javascript.
this is my app.py :
@app.route('/bestApp', methods=['GET', 'POST'])
def bestapp():
app_data = AppDataFromUrl(app_url)
json.dumps(app_data)
permitted_directory='static/assets/upload/'
return send_from_directory(directory=permitted_directory, path=filename,as_attachment=True)
and this is my script.js
async function getExtract() {
try {
const response = await fetch("/bestApp", {
method: "post",
body: new FormData(document.querySelector(".testform")),
});
console.log(response);
}
whenever i download my file, it works but the problem is the link that shown in browser is like “http://127.0.0.1:5000/bestApp”
how to convert http://127.0.0.1:5000/bestApp to normal URL? such http://127.0.0.1:5000/42342jnkjsahdkajsda87391237921dask.
I don’t wanna use Blob Object Url or Data URI.