Added Main Programm

Added the Main Programm i coded before!
This commit is contained in:
Jonas
2022-09-27 15:08:14 +02:00
committed by GitHub
parent 98ce09c169
commit 36066b297e
18 changed files with 193 additions and 0 deletions

27
main.py Normal file
View File

@@ -0,0 +1,27 @@
from flask import *
from render.initer import load_themes, render_pic
import os
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)
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 = 'render/outputs'
for f in os.listdir(dirs):
os.remove(os.path.join(dirs, f))
themes = load_themes()
app.run(port=888)