-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0aa54b4
commit f3bc392
Showing
9 changed files
with
29 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.8 | ||
FROM python:3.9-slim-buster | ||
|
||
WORKDIR /app | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from db import session | ||
|
||
|
||
def create_tables(): | ||
return session.Base.metadata.create_all(bind=session.engine) | ||
|
||
def get_db(): | ||
db = session.SessionLocal() | ||
try: | ||
yield db | ||
finally: | ||
db.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
from sqlalchemy import create_engine | ||
from sqlalchemy.orm import sessionmaker | ||
from sqlalchemy.ext.declarative import declarative_base | ||
from config import DATABASE_URL | ||
import sqlalchemy as _sql | ||
import sqlalchemy.ext.declarative as _declarative | ||
import sqlalchemy.orm as _orm | ||
import config | ||
|
||
engine = _sql.create_engine(config.DATABASE_URL) | ||
|
||
engine = create_engine(DATABASE_URL) | ||
SessionLocal = _orm.sessionmaker(autocommit=False, autoflush=False, bind=engine) | ||
|
||
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) | ||
|
||
Base = declarative_base() | ||
Base = _declarative.declarative_base() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,12 @@ | ||
from fastapi import FastAPI, Depends | ||
from fastapi import FastAPI | ||
from api.routes import audio | ||
from middlewares import cors_middleware | ||
from typing import Annotated | ||
from sqlalchemy.orm import Session | ||
from db.init_db import init_db | ||
from db.utils import get_db | ||
import db | ||
|
||
db.services.create_tables() | ||
|
||
app = FastAPI() | ||
|
||
@app.on_event("startup") | ||
async def startup_event(): | ||
init_db() | ||
|
||
cors_middleware.setup_cors(app) | ||
|
||
db_dependency = Annotated[Session, Depends(get_db)] | ||
|
||
app.include_router(audio.router) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters