Get db name from environment variable
This commit is contained in:
parent
b1905cc03a
commit
191168335a
1 changed files with 3 additions and 3 deletions
6
main.py
6
main.py
|
|
@ -10,10 +10,12 @@ from fastapi.encoders import jsonable_encoder
|
|||
|
||||
app = FastAPI()
|
||||
|
||||
import os
|
||||
DATABASE_PATH = os.environ.get('DOOF_DB', './data/doof.sqlite')
|
||||
|
||||
# Dependency to create SQLite connection
|
||||
async def get_db():
|
||||
sql_db = await db.connect()
|
||||
sql_db = await db.connect(DATABASE_PATH)
|
||||
try:
|
||||
yield sql_db
|
||||
finally:
|
||||
|
|
@ -354,8 +356,6 @@ async def login(data: LoginBody, conn: sqlite3.Connection = Depends(get_db)) ->
|
|||
async def current_user(user: persons.Person = Depends(cookie_person)) -> persons.Person:
|
||||
return user
|
||||
|
||||
import os
|
||||
|
||||
if os.environ.get('DOOF_PROD', False):
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
app.mount("/", StaticFiles(directory="./front-dist", html=True), name="front-dist")
|
||||
|
|
|
|||
Loading…
Reference in a new issue