backend/fastapi/app/main.py

79 lines
1.7 KiB
Python

import time
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
import logging
import datetime
from router.router_api import router as router_api
from router.card_service import router as router_card
from router.image_api import router as image_api
from router.manage_user_api import router as manage_user_api
from router.room_score_api import router as room_score_api
# test
from router.test_service import router as test_service_api
# firebase
from process.firebase.firebase_app import initialize_firebase
app = FastAPI()
# Firebase 초기화
initialize_firebase()
# docker로 수행하기 때문에 로그는 생략
# logger = logging.getLogger()
# logger.setLevel(logging.INFO)
# file_handler = logging.FileHandler("testtest.log")
# logger.addHandler(file_handler)
# -----------------------------------------------------------------------------------------------
# CORS 설정
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # 모든 도메인 허용 (필요에 따라 수정)
allow_credentials=True,
allow_methods=["*"], # 모든 HTTP 메서드 허용
allow_headers=["*"], # 모든 헤더 허용
)
# /api
app.include_router(router_api)
# /api/card
app.include_router(router_card)
# /images
app.include_router(image_api)
# /user
app.include_router(manage_user_api)
# /room/score
app.include_router(room_score_api)
# /test
app.include_router(test_service_api)
# /iot-kt
# app.include_router(router_iot_kt)
# /iot-lg
# app.include_router(router_iot_lg)
@app.get("/ttt")
async def test_endpoint(data: dict):
return {"get received_data": data}
@app.post("/ttt")
async def test_endpoint(data: dict):
return {"received_data": data}