Удалил всякое не нужное
This commit is contained in:
parent
527b84554a
commit
f75af08be6
3
fastapi-app-upload/.dockeringore
Normal file
3
fastapi-app-upload/.dockeringore
Normal file
@ -0,0 +1,3 @@
|
||||
venv
|
||||
Dockerfile
|
||||
tasks.db
|
4
fastapi-app-upload/.gitignore
vendored
Normal file
4
fastapi-app-upload/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
venv
|
||||
tasks.db
|
||||
.idea
|
||||
__pycache__
|
14
fastapi-app-upload/Dockerfile
Normal file
14
fastapi-app-upload/Dockerfile
Normal file
@ -0,0 +1,14 @@
|
||||
FROM python:3.11-slim
|
||||
|
||||
COPY ../../../../../AppData/Local/Temp .
|
||||
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80"]
|
||||
|
||||
# Для запуска введите две команды:
|
||||
# docker build . --tag fastapi_app
|
||||
# docker run -p 80:80 fastapi_app
|
||||
|
||||
# Или одной командой
|
||||
# docker build . --tag fastapi_app && docker run -p 80:80 fastapi_app
|
BIN
fastapi-app-upload/README.md
Normal file
BIN
fastapi-app-upload/README.md
Normal file
Binary file not shown.
18
fastapi-app-upload/database/database.py
Normal file
18
fastapi-app-upload/database/database.py
Normal file
@ -0,0 +1,18 @@
|
||||
from datetime import datetime
|
||||
from sqlalchemy.ext.asyncio import create_async_engine, async_sessionmaker
|
||||
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, relationship
|
||||
from sqlalchemy import ForeignKey
|
||||
|
||||
engine = create_async_engine("sqlite+aiosqlite:///tasks.db")
|
||||
new_session = async_sessionmaker(engine, expire_on_commit=False)
|
||||
|
||||
class Base(DeclarativeBase):
|
||||
pass
|
||||
|
||||
async def create_tables():
|
||||
async with engine.begin() as conn:
|
||||
await conn.run_sync(Base.metadata.create_all)
|
||||
|
||||
async def delete_tables():
|
||||
async with engine.begin() as conn:
|
||||
await conn.run_sync(Base.metadata.drop_all)
|
22
fastapi-app-upload/main.py
Normal file
22
fastapi-app-upload/main.py
Normal file
@ -0,0 +1,22 @@
|
||||
from fastapi import FastAPI
|
||||
|
||||
from contextlib import asynccontextmanager
|
||||
|
||||
from database.database import create_tables, delete_tables
|
||||
from routers.csv_router import router as csv_router
|
||||
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
await delete_tables()
|
||||
print("База очищена")
|
||||
await create_tables()
|
||||
print("База готова к работе")
|
||||
yield
|
||||
print("Выключение")
|
||||
|
||||
|
||||
app = FastAPI(lifespan=lifespan)
|
||||
app.include_router(csv_router)
|
||||
|
BIN
fastapi-app-upload/requirements.txt
Normal file
BIN
fastapi-app-upload/requirements.txt
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user