-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
58 lines (43 loc) · 1.1 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import json
import logging
import logging.config
import os
from pathlib import Path
from dotenv import load_dotenv
from flask_orjson import OrjsonProvider
from quart import Quart
from quart_schema import QuartSchema, hide
from tortoise.contrib.quart import register_tortoise
from casa.api import blueprint as casa_api
load_dotenv()
with open(Path(__file__).parent / "logger_config.json", "r") as f:
logging.config.dictConfig(json.load(f))
logger = logging.getLogger(__name__)
app = Quart(__name__)
app.json = OrjsonProvider(app)
QuartSchema(app)
@app.get("/healthz")
@hide
async def health():
return "running"
@app.get("/ready")
@hide
async def ready():
return "ready"
app.register_blueprint(casa_api, url_prefix="/api/casa")
TORTOISE_ORM = {
"connections": {"default": os.environ.get("DATABASE_URL")},
"apps": {
"models": {
"models": ["casa.models", "aerich.models"],
"default_connection": "default",
}
},
}
register_tortoise(
app,
config=TORTOISE_ORM,
generate_schemas=False,
)
if __name__ == "__main__":
app.run(debug=True)