download work

This commit is contained in:
Sébastien Thuret 2021-10-24 18:44:35 +02:00
parent f0d6c92db7
commit 4f0d19dbc4
No known key found for this signature in database
GPG key ID: 4742E2D66933BB08

View file

@ -6,7 +6,7 @@ from functools import wraps
import argostranslatefiles import argostranslatefiles
import pkg_resources import pkg_resources
from argostranslatefiles import get_supported_formats from argostranslatefiles import get_supported_formats
from flask import Flask, abort, jsonify, render_template, request, url_for from flask import Flask, abort, jsonify, render_template, request, url_for, send_from_directory
from flask_swagger import swagger from flask_swagger import swagger
from flask_swagger_ui import get_swaggerui_blueprint from flask_swagger_ui import get_swaggerui_blueprint
from translatehtml import translate_html from translatehtml import translate_html
@ -601,11 +601,13 @@ def create_app(args):
@app.route("/download_file/<string:filename>", methods=["GET"]) @app.route("/download_file/<string:filename>", methods=["GET"])
@access_check @access_check
def download_file(filename): def download_file(filename: str):
""" """
Download a translated file Download a translated file
""" """
print('') filename.split('.').pop(0)
return send_from_directory(directory=tempfile.gettempdir(), filename=filename)
@app.route("/detect", methods=["POST"]) @app.route("/detect", methods=["POST"])
@access_check @access_check