-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
29 lines (24 loc) · 813 Bytes
/
main.py
File metadata and controls
29 lines (24 loc) · 813 Bytes
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
from flask import Flask, request
import json
import os
from importlib import import_module
from context import Context
from colorama import init, Fore
app = Flask(__name__)
@app.route('/')
def root():
return 'hi there'
@app.errorhandler(404)
def err(e):
print(f'{Fore.YELLOW}Unhandled request! {Fore.LIGHTWHITE_EX}{request.path} {Fore.LIGHTBLACK_EX}{json.dumps(request.values.to_dict())}{Fore.RESET}')
return '-1'
ctx = Context
ctx.app = app
init() # init colorama
for root, _, files in os.walk('routes'):
for file in files:
if not file.endswith('.py'): continue
# this is very hacky but whatever
path = os.path.join(root, file[:-3]).replace(os.sep, '.')
print(f'{Fore.LIGHTBLACK_EX}Importing module: {Fore.RESET}{path}')
import_module(path).setup(ctx)