File size: 564 Bytes
ed5c4dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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}