Create main.py
Browse files
main.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 3 |
+
from pydantic import BaseModel
|
| 4 |
+
|
| 5 |
+
app = FastAPI(title="Lythron API", version="EVO.3")
|
| 6 |
+
|
| 7 |
+
# CORS para permitir frontend
|
| 8 |
+
app.add_middleware(
|
| 9 |
+
CORSMiddleware,
|
| 10 |
+
allow_origins=["*"], # cambiar por dominio final al publicar
|
| 11 |
+
allow_credentials=True,
|
| 12 |
+
allow_methods=["*"],
|
| 13 |
+
allow_headers=["*"],
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
class Message(BaseModel):
|
| 17 |
+
message: str
|
| 18 |
+
|
| 19 |
+
@app.get("/")
|
| 20 |
+
def root():
|
| 21 |
+
return {"message": "Servidor Lythron API en ejecuci贸n 馃殌"}
|
| 22 |
+
|
| 23 |
+
@app.post("/chat")
|
| 24 |
+
def chat(msg: Message):
|
| 25 |
+
# Esto lo pod茅s conectar luego con Hugging Face, OpenAI o tu modelo local
|
| 26 |
+
return {"reply": f"Lythron responde: '{msg.message}' procesado exitosamente."}
|