alexander1010 commited on
Commit
b41e915
·
verified ·
1 Parent(s): c71e312

fix: habilitar Swagger UI en Hugging Face

Browse files
Files changed (1) hide show
  1. main.py +18 -6
main.py CHANGED
@@ -1,5 +1,6 @@
1
  from fastapi import FastAPI
2
- from fastapi.middleware.cors import CORSMiddleware # 👈 nuevo
 
3
 
4
  # routers
5
  from src.expon.iam.interfaces.rest.controllers.auth_controller import router as auth_router
@@ -13,10 +14,13 @@ from src.expon.shared.infrastructure.database import Base, engine
13
  app = FastAPI(
14
  title="Expon Backend API",
15
  version="1.0.0",
16
- description="Backend estructurado por bounded contexts con FastAPI"
 
 
 
17
  )
18
 
19
- # 👇 middleware CORS
20
  origins = [
21
  "https://expon-frontend.netlify.app",
22
  "http://localhost:4200",
@@ -30,7 +34,7 @@ app.add_middleware(
30
  allow_headers=["*"],
31
  )
32
 
33
- # routers
34
  app.include_router(auth_router, prefix="/api/v1/auth", tags=["Authentication"])
35
  app.include_router(profile_router, prefix="/api/v1/profile", tags=["Profile"])
36
  app.include_router(presentation_router, prefix="/api/v1/presentation", tags=["Presentations"])
@@ -39,6 +43,14 @@ app.include_router(subscription_router, prefix="/api/v1/subscription", tags=["Su
39
 
40
  Base.metadata.create_all(bind=engine)
41
 
42
- @app.get("/")
43
  def read_root():
44
- return {"mensaje": "¡Expon backend funcionando con estructura profesional!"}
 
 
 
 
 
 
 
 
 
1
  from fastapi import FastAPI
2
+ from fastapi.middleware.cors import CORSMiddleware
3
+ from fastapi.responses import HTMLResponse # 👈 nuevo
4
 
5
  # routers
6
  from src.expon.iam.interfaces.rest.controllers.auth_controller import router as auth_router
 
14
  app = FastAPI(
15
  title="Expon Backend API",
16
  version="1.0.0",
17
+ description="Backend estructurado por bounded contexts con FastAPI",
18
+ docs_url="/docs", # 👈 habilita /docs
19
+ redoc_url="/redoc", # 👈 opcional: documentación alternativa
20
+ openapi_url="/openapi.json" # 👈 necesaria para Swagger
21
  )
22
 
23
+ # CORS
24
  origins = [
25
  "https://expon-frontend.netlify.app",
26
  "http://localhost:4200",
 
34
  allow_headers=["*"],
35
  )
36
 
37
+ # Rutas principales
38
  app.include_router(auth_router, prefix="/api/v1/auth", tags=["Authentication"])
39
  app.include_router(profile_router, prefix="/api/v1/profile", tags=["Profile"])
40
  app.include_router(presentation_router, prefix="/api/v1/presentation", tags=["Presentations"])
 
43
 
44
  Base.metadata.create_all(bind=engine)
45
 
46
+ @app.get("/", response_class=HTMLResponse)
47
  def read_root():
48
+ return """
49
+ <html>
50
+ <head><title>Expon Backend</title></head>
51
+ <body style="font-family: Arial; text-align: center; margin-top: 50px;">
52
+ <h1>✅ ¡Expon backend funcionando con estructura profesional!</h1>
53
+ <p><a href="/docs" style="font-size: 18px; color: #007bff;">Ver documentación Swagger</a></p>
54
+ </body>
55
+ </html>
56
+ """