Files
eventspace/backend/app/main.py
Felipe Cardoso b47dbaeb0b
Some checks failed
Build and Push Docker Images / changes (push) Successful in 4s
Build and Push Docker Images / build-backend (push) Successful in 50s
Build and Push Docker Images / build-frontend (push) Failing after 47s
Refactor file upload to use SDK instead of XMLHttpRequest
Replaced manual XMLHttpRequest implementation with the SDK's `uploadFile` method for handling file uploads to presigned URLs. This simplifies the code, leverages built-in features like progress tracking, and improves error handling. Added token extraction and upload progress updates to maintain functionality.
2025-03-14 00:05:26 +01:00

52 lines
1.3 KiB
Python

import logging
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import HTMLResponse
from fastapi.staticfiles import StaticFiles
from app.api.router import api_router
from app.core.config import settings
scheduler = AsyncIOScheduler()
logger = logging.getLogger(__name__)
logger.info(f"Starting app!!!")
app = FastAPI(
title=settings.PROJECT_NAME,
version=settings.VERSION,
openapi_url=f"{settings.API_VERSION_STR}/openapi.json",
debug=True,
)
# Set up CORS middleware
app.add_middleware(
CORSMiddleware,
allow_origins=settings.BACKEND_CORS_ORIGINS,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.get("/", response_class=HTMLResponse)
async def root():
return """
<html>
<head>
<title>EventSpace API</title>
</head>
<body>
<h1>Welcome to EventSpace API</h1>
<p>Explore the available endpoints and documentation:</p>
<a href="/docs">OpenAPI Documentation</a>
</body>
</html>
"""
app.include_router(api_router, prefix=settings.API_VERSION_STR)
app.mount("/files", StaticFiles(directory=settings.DATA_FILES_DIR), name="static")