revert main.py

This commit is contained in:
Jörn-Michael Miehe 2022-03-20 03:59:25 +00:00
parent e49a993676
commit ecb97df3d6

View file

@ -17,25 +17,10 @@ from .db import Connection
from .db.schemas import User from .db.schemas import User
from .routers import admin, user from .routers import admin, user
app = FastAPI()
@app.on_event("startup")
async def on_startup() -> None:
# check if configured
if (current_config := await Config.load()) is not None:
# connect to database
Connection.connect(await current_config.db.db_engine)
# some testing
with Connection.use() as db:
print(User.from_db(db, "admin"))
print(User.from_db(db, "nonexistent"))
def main() -> None:
settings = Settings.get() settings = Settings.get()
app = FastAPI()
api = FastAPI( api = FastAPI(
title="kiwi-vpn API", title="kiwi-vpn API",
description="This API enables the `kiwi-vpn` service.", description="This API enables the `kiwi-vpn` service.",
@ -57,6 +42,21 @@ def main() -> None:
app.mount("/api", api) app.mount("/api", api)
@app.on_event("startup")
async def on_startup() -> None:
# check if configured
if (current_config := await Config.load()) is not None:
# connect to database
Connection.connect(await current_config.db.db_engine)
# some testing
with Connection.use() as db:
print(User.from_db(db, "admin"))
print(User.from_db(db, "nonexistent"))
def main() -> None:
uvicorn.run( uvicorn.run(
"kiwi_vpn_api.main:app", "kiwi_vpn_api.main:app",
host="0.0.0.0", host="0.0.0.0",