Created
September 8, 2022 13:51
-
-
Save temach/33b8c6be3e8aab8ca04a5cb5fb7db5e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io | |
import uuid | |
import time | |
from flask import Flask, jsonify, request, send_file, render_template, make_response | |
APP = Flask(__name__) | |
VERSION = "1.0" | |
def process(data): | |
# do some work | |
time.sleep(10) | |
# load file | |
newdata = {} | |
return newdata | |
@APP.route('/upload_form', methods=['GET']) | |
def get_upload_form(): | |
return render_template("upload_form.html") | |
@APP.route('/upload_file', methods=['POST']) | |
def process(): | |
if 'inputfile' in request.files: | |
inputfile = request.files['inputfile'].get() | |
else: | |
APP.logger.info('no file') | |
return make_response(jsonify(error="no file"), 400) | |
retval = process(inputfile) | |
return make_response(jsonify(retval)) | |
if __name__ == "__main__": | |
from waitress import serve | |
port = 8000 | |
serve(APP, host="0.0.0.0", port=port) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment