-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
33 lines (25 loc) · 958 Bytes
/
run.py
File metadata and controls
33 lines (25 loc) · 958 Bytes
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
"""
Создание приложения, регистрация endpoints,
Переадресация для главной страницы
Запуск приложения
"""
import uvicorn
from fastapi import FastAPI
from fastapi.responses import RedirectResponse
from app.config import config
from app.logger import log
from app.routers import tasks
# Создание приложения
app = FastAPI(title="Task Hub")
log.debug('App created: %s', app)
# Регистрация эндпоинтов
app.include_router(tasks.router, prefix='/tasks', tags=["Tasks"])
log.debug('Router registered: /tasks')
@app.get("/", include_in_schema=False)
async def redirect_to_docs():
"""Redirect to /openapi.json when accessing "/" endpoint"""
return RedirectResponse(url="/docs")
# Запуск приложения
if __name__ == "__main__":
log.info('Configuration loaded: %s', config.config_type)
uvicorn.run(app, host='0.0.0.0')