-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
21 lines (17 loc) · 735 Bytes
/
run.py
File metadata and controls
21 lines (17 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import asyncio
import uvicorn
from fastapi import FastAPI
from config import settings
from api.wireguard_handlers import wireguard_router
from api.db.database import async_engine, Base
from api.db.models import Wireguard # Нужно для нормального функционирования metadata в Base
app = FastAPI(root_path="/api")
app.include_router(wireguard_router)
async def init_db():
async with async_engine.begin() as conn:
await conn.run_sync(Base.metadata.drop_all)
await conn.run_sync(Base.metadata.create_all)
print("Database table created!!!")
if __name__ == "__main__":
asyncio.run(init_db())
uvicorn.run(app="run:app", host=settings.run.host, port=settings.run.port)