-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
39 lines (33 loc) · 1023 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from flask import Flask, render_template
from flask_cors import CORS
from routes import ROOT
from src.tools import RegexConverter, Manager, PATH
from src.html_render import HTMLRender
from threading import Timer
import os
import shutil
# Create a new Flask application
app = Flask(__name__, template_folder="public", static_folder="public/static")
app.url_map.converters['regex'] = RegexConverter
app.config['SECRET_KEY'] = 'secret'
CORS(app)
Manager.app = app
# Regenerate the builds folder
if os.path.exists("public/builds"):
shutil.rmtree("public/builds")
os.mkdir("public/builds")
Manager.builds = []
# Not found route
@app.errorhandler(404)
def not_found(error):
return render_template("not-found.html"), 404
# Register the routes
for route in ROOT:
app.route(
rule=route["path"],
methods=route["methods"]
)(route['func'])
if __name__ == "__main__":
Timer(.25, HTMLRender.init, args=(PATH,)).start()
print("\n\x1b[1;32m[Flask]\x1b[0m - Initializing...\n")
app.run()