-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
61 lines (50 loc) · 1.67 KB
/
app.py
File metadata and controls
61 lines (50 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from fastapi import FastAPI, HTTPException
from dotenv import load_dotenv
import logging
from fastapi.middleware.cors import CORSMiddleware
from shared.custom_error import raise_custom_error
from shared.custom_messages import CustomMessages
from shared.custom_response import CustomResponse
from shared.exception_filter import ExceptionFilter
from shared.constants import HTTPCodes,GlobalConstants
from user_module.user_router import user_router
log_file_path = GlobalConstants.log_file_path
load_dotenv()
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
logging.FileHandler(log_file_path),
logging.StreamHandler()
]
)
app = FastAPI(
title="InterviewMate Backend Service",
description="Mock Interview Platform",
version="1.0.0",
docs_url="/api/docs",
openapi_url="/api/openapi.json"
)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # Allows all origins to access your app
allow_credentials=True,
allow_methods=["*"], # Allows all methods (GET, POST, etc.)
allow_headers=["*"], # Allows all headers
)
app.add_exception_handler(HTTPException, ExceptionFilter.custom_http_exception_handler)
@app.get("/api/health")
async def health_check():
try:
return CustomResponse(
status_code=HTTPCodes.OK,
message=CustomMessages.service_working,
result=None
)
except Exception as e:
raise_custom_error(
status_code=HTTPCodes.INTERNAL_SERVER_ERROR,
message=CustomMessages.internal_server_err,
error=None
)
app.include_router(router=user_router)