forked from consumer-ai-lab/medbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
45 lines (34 loc) · 1.2 KB
/
app.py
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
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from starlette.middleware.sessions import SessionMiddleware
from .routes.main import router
from .database.config import Base,engine
from starlette.middleware.base import BaseHTTPMiddleware
from starlette.requests import Request
import json
import os
Base.metadata.create_all(bind=engine)
SECRET_KEY = os.getenv('SECRET_KEY')
GOOGLE_CLIENT_SECRET = os.getenv("GOOGLE_CLIENT_SECRET")
app = FastAPI(root_path="/api/auth")
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"]
)
class LoggingMiddleware(BaseHTTPMiddleware):
async def dispatch(self, request: Request, call_next):
body = await request.body()
print(f"Request body: {body.decode()}")
print(f"Request headers: {dict(request.headers)}")
print(f"Request path: {request.url.path}")
response = await call_next(request)
print(f"Response status: {response.status_code}")
return response
app.add_middleware(LoggingMiddleware)
app.include_router(router=router)
@app.get('/')
async def root():
return {"message":"Hello from auth service."}