-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
37 lines (26 loc) · 830 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
from typing import Literal
import fastapi
import uvicorn
import src.app.routes
import src.crons.crons
import src.db.inmemory.db
app = fastapi.FastAPI()
db = src.db.inmemory.db.InMemoryDatabase(config=src.db.Database.Config(
dbname="postgres",
user="postgres",
host="localhost",
password=None
))
src.app.routes.register(app, db)
src.crons.crons.start_background_tasks(app, db)
def main():
start_server(num_workers=1, reload=False, host='0.0.0.0')
def start_server(host='127.0.0.1', port=8000, num_workers=4,
loop: Literal["none", "auto", "asyncio", "uvloop"] = 'auto', reload=False):
uvicorn.run('main:app', host=host,
port=port,
workers=num_workers,
loop=loop,
reload=reload)
if __name__ == '__main__':
main()