testingesp32 / app.py
1MR's picture
Create app.py
ed5c4dd verified
raw
history blame contribute delete
564 Bytes
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
# Request schema
class DataRequest(BaseModel):
message: str
# Static value
STATIC_VALUE = "Hello from Hugging Face Space!"
@app.get("/")
def root():
return {"info": "FastAPI app is running on Hugging Face Spaces"}
@app.post("/send")
def send_data(data: DataRequest):
# Just return the static value regardless of input
return {
"received": data.message,
"response": STATIC_VALUE
}
@app.get("/get")
def get_data():
return {"data": STATIC_VALUE}