fastfood/manage.py

35 lines
668 B
Python
Raw Normal View History

import asyncio
2024-01-18 21:15:56 +03:00
import sys
import uvicorn
from fastfood.repository import create_db_and_tables
2024-01-18 21:15:56 +03:00
def run_app():
"""
Запуск FastAPI
2024-01-18 21:15:56 +03:00
"""
uvicorn.run(
app="fastfood.app:create_app",
2024-01-28 16:22:24 +03:00
host="0.0.0.0",
port=8000,
2024-01-18 21:15:56 +03:00
reload=True,
factory=True,
2024-01-28 16:22:24 +03:00
workers=1,
2024-01-18 21:15:56 +03:00
)
async def recreate():
"""Удаление и создание таблиц в базе данных для тестирования"""
await create_db_and_tables()
2024-01-18 21:15:56 +03:00
if __name__ == "__main__":
2024-01-18 21:15:56 +03:00
if "--run-server" in sys.argv:
run_app()
if "--run-test-server" in sys.argv:
asyncio.run(recreate())
2024-01-18 21:15:56 +03:00
run_app()