Add vercel

This commit is contained in:
2022-09-29 20:43:05 +02:00
parent 80807adf3d
commit 5282e1b0fd
6 changed files with 24 additions and 33 deletions

29
main.py Normal file
View File

@@ -0,0 +1,29 @@
from flask import *
from render.initer import load_themes, render_pic
import os
THIS_FOLDER = os.path.dirname(os.path.abspath(__file__))
app = Flask(__name__)
@app.route("/", methods=["GET"])
def create_pic():
name_query = str(request.args.get("name"))
theme_query = str(request.args.get("t"))
filename = render_pic(themes, name_query, theme_query, THIS_FOLDER)
if filename == "error":
return "<h1>error</h1><br><h3>check if theme exist or name & theme is given!</h3>"
return send_file(filename, mimetype='image/gif')
if __name__ == "__main__":
dirs = os.path.join(THIS_FOLDER, "render/outputs")
for f in os.listdir(dirs):
os.remove(os.path.join(dirs, f))
themes = load_themes(THIS_FOLDER)
app.run()