Initial commit - cleaned repository
This commit is contained in:
65
services/images/backend/main.py
Normal file
65
services/images/backend/main.py
Normal file
@ -0,0 +1,65 @@
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from contextlib import asynccontextmanager
|
||||
import uvicorn
|
||||
from datetime import datetime
|
||||
|
||||
from app.api.endpoints import router
|
||||
from app.core.config import settings
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
# 시작 시
|
||||
print("Images service starting...")
|
||||
yield
|
||||
# 종료 시
|
||||
print("Images service stopping...")
|
||||
|
||||
app = FastAPI(
|
||||
title="Images Service",
|
||||
description="이미지 업로드, 프록시 및 캐싱 서비스",
|
||||
version="2.0.0",
|
||||
lifespan=lifespan
|
||||
)
|
||||
|
||||
# CORS 설정
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"],
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
# 라우터 등록
|
||||
app.include_router(router, prefix="/api/v1")
|
||||
|
||||
@app.get("/")
|
||||
async def root():
|
||||
return {
|
||||
"service": "Images Service",
|
||||
"version": "2.0.0",
|
||||
"timestamp": datetime.now().isoformat(),
|
||||
"endpoints": {
|
||||
"proxy": "/api/v1/image?url=<image_url>&size=<optional_size>",
|
||||
"upload": "/api/v1/upload",
|
||||
"stats": "/api/v1/stats",
|
||||
"cleanup": "/api/v1/cleanup"
|
||||
}
|
||||
}
|
||||
|
||||
@app.get("/health")
|
||||
async def health_check():
|
||||
return {
|
||||
"status": "healthy",
|
||||
"service": "images",
|
||||
"timestamp": datetime.now().isoformat()
|
||||
}
|
||||
|
||||
if __name__ == "__main__":
|
||||
uvicorn.run(
|
||||
"main:app",
|
||||
host="0.0.0.0",
|
||||
port=8000,
|
||||
reload=True
|
||||
)
|
||||
Reference in New Issue
Block a user