1MR commited on
Commit
ed5c4dd
·
verified ·
1 Parent(s): 5acd58d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from pydantic import BaseModel
3
+
4
+ app = FastAPI()
5
+
6
+ # Request schema
7
+ class DataRequest(BaseModel):
8
+ message: str
9
+
10
+ # Static value
11
+ STATIC_VALUE = "Hello from Hugging Face Space!"
12
+
13
+ @app.get("/")
14
+ def root():
15
+ return {"info": "FastAPI app is running on Hugging Face Spaces"}
16
+
17
+ @app.post("/send")
18
+ def send_data(data: DataRequest):
19
+ # Just return the static value regardless of input
20
+ return {
21
+ "received": data.message,
22
+ "response": STATIC_VALUE
23
+ }
24
+
25
+ @app.get("/get")
26
+ def get_data():
27
+ return {"data": STATIC_VALUE}