-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
49 lines (32 loc) · 955 Bytes
/
main.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
40
41
42
43
44
45
46
47
48
49
from lightberry import Server, App, AppContext
from lightberry.utils import common_utils, files_utils
def create_routers(app):
from routes import api, core, home
app.add_router(api)
app.add_router(home)
core.set_catch_all_excluded_routes(app.get_routers_prefixes())
app.add_router(core)
def setup_tasks(app):
import tasks
app.add_background_task(tasks.ExampleAsyncTask())
# app.add_background_task(tasks.ExampleThreadingTask())
def setup_app(app):
setup_tasks(app)
create_routers(app)
def main():
common_utils.print_debug(f"Free space: {files_utils.get_free_space()} kB",
debug_enabled=True)
# app = App()
#
# with AppContext(app):
# setup_app(app)
#
# server = Server(app=app)
# server.start()
# Or
app = App()
with AppContext(app):
setup_app(app)
app.run()
if __name__ == '__main__':
main()