import os
import shutil
import random
from flask import Flask, request, jsonify, send_from_directory, make_response
from werkzeug.exceptions import BadRequest
app = Flask(__name__)
app.config["APP_WEB_STATIC_PATH"] = os.path.normpath(os.getcwd())
@app.errorhandler(Exception)
def handle_generic_exception(e: Exception):
return str(e), 500
@app.errorhandler(BadRequest)
def handle_generic_exception(e: BadRequest):
return str(e), 400
@app.route("/api/v1/hello")
def rename():
itemx = ["Hello", "World"]
return jsonify(itemx)
@app.route("/submit", methods=["POST"])
def upload():
return make_response(str(request.form) + "\r\nOK")
@app.route("/", defaults={"path": "index.html"})
@app.route("/<path:path>")
def default(path):
return send_from_directory(app.config["APP_WEB_STATIC_PATH"], path)
if __name__ == "__main__":
app.run(debug=True)