Skip to content

Commit

Permalink
fix: 백엔드 서버 파일 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
C7C4FF committed Aug 31, 2024
1 parent e5006d5 commit 68fdc0d
Showing 1 changed file with 1 addition and 34 deletions.
35 changes: 1 addition & 34 deletions Backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,8 @@
from auth_router import router as auth_router
from fastapi import FastAPI
from starlette.middleware.sessions import SessionMiddleware
from fastapi.middleware.cors import CORSMiddleware
from test_router import router as test_router

#date, score 받아오는 엔드포인트 설정
from fastapi import Depends
from sqlalchemy.orm import Session
from database import SessionLocal, engine
from models import Score

app = FastAPI()
app.include_router(auth_router, prefix="/api")
app.include_router(test_router, prefix="/api")
Expand All @@ -31,34 +24,8 @@ def load_config(filename):
SessionMiddleware, secret_key=google_config.get("middleware_secret_key")
)

app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # 또는 특정 도메인을 설정
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)

@app.middleware("http")
async def add_coop_header(request, call_next):
response = await call_next(request)
response.headers['Cross-Origin-Opener-Policy'] = 'same-origin-allow-popups'
return response

# 기본 연결 확인
@app.get("/")
def connection_test_handler():
return {"Dunning": "Kruger"}

#date, score 받아오는 엔드포인트 설정
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()

@app.get("/api/scores/")
def get_scores(db: Session = Depends(get_db)):
scores = db.query(Score).all() # 모든 Score 객체 가져오기
return scores
return {"Dunning": "Kruger"}

1 comment on commit 68fdc0d

@C7C4FF
Copy link
Contributor Author

@C7C4FF C7C4FF commented on 68fdc0d Aug 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#80

Please sign in to comment.