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