2024-01-19 03:15:48 +03:00
|
|
|
import asyncio
|
2024-01-18 21:15:56 +03:00
|
|
|
import sys
|
|
|
|
|
|
|
|
import uvicorn
|
|
|
|
|
2024-02-02 23:38:12 +03:00
|
|
|
from fastfood.repository 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",
|
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
|
|
|
)
|
|
|
|
|
|
|
|
|
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()
|