Skip to content

Commit 2413133

Browse files
surajitsurajit
authored andcommitted
modify app.py
1 parent 430a44d commit 2413133

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

app.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
import os
2+
13
from fastapi import FastAPI
24
from fastapi import Request
35
from fastapi.templating import Jinja2Templates
46

57
from routes.v1 import email
68
from routes.v1 import contact
79
from routes.v1 import company
10+
from settings import LOG_FILE
811

912
app = FastAPI()
1013
app.include_router(email.router)
@@ -19,3 +22,14 @@ def home(request: Request):
1922
return templates.TemplateResponse(
2023
"charge.html", {"request": request, "message": "Welcome to Property Management API"}
2124
)
25+
26+
27+
@app.on_event("startup")
28+
async def startup_event():
29+
try:
30+
os.makedirs(LOG_FILE)
31+
if not os.path.exists(LOG_FILE):
32+
os.mknod(LOG_FILE)
33+
except FileExistsError:
34+
# directory already exists
35+
pass

0 commit comments

Comments
 (0)