|
|
from fastapi import FastAPI |
|
|
from fastapi.middleware.cors import CORSMiddleware |
|
|
from pydantic import BaseModel |
|
|
|
|
|
app = FastAPI(title="Lythron API", version="EVO.3") |
|
|
|
|
|
|
|
|
app.add_middleware( |
|
|
CORSMiddleware, |
|
|
allow_origins=["*"], |
|
|
allow_credentials=True, |
|
|
allow_methods=["*"], |
|
|
allow_headers=["*"], |
|
|
) |
|
|
|
|
|
class Message(BaseModel): |
|
|
message: str |
|
|
|
|
|
@app.get("/") |
|
|
def root(): |
|
|
return {"message": "Servidor Lythron API en ejecución 🚀"} |
|
|
|
|
|
@app.post("/chat") |
|
|
def chat(msg: Message): |
|
|
|
|
|
return {"reply": f"Lythron responde: '{msg.message}' procesado exitosamente."} |
|
|
|