Spaces:
Running
Running
import os | |
from flask import Flask, send_file, request, jsonify | |
from utils.handle_file import file_handler | |
from werkzeug.utils import secure_filename | |
app = Flask(__name__) | |
app.config['MAX_CONTENT_LENGTH'] = 11 * 1024 * 1024 | |
def index(): | |
return send_file('src/index.html') | |
def upload(): | |
try: | |
if 'file' not in request.files: | |
return jsonify({"error": "No filet"}), 400 | |
file = request.files['file'] | |
if file.filename == '': | |
return jsonify({"error": "No selected file"}), 400 | |
return file_handler.process_file(file) | |
except Exception as e: | |
return {"error": f"an error occured: {e}"}, 500 | |
def main(): | |
app.run(host='0.0.0.0', port=7860, debug=True) | |
if __name__ == "__main__": | |
main() | |