Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
from fastapi.responses import JSONResponse
|
| 3 |
+
import json
|
| 4 |
+
|
| 5 |
+
app = FastAPI()
|
| 6 |
+
|
| 7 |
+
# Load JSON once
|
| 8 |
+
with open("materials_data.json", "r") as f:
|
| 9 |
+
materials_data = json.load(f)
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
@app.get("/")
|
| 13 |
+
def home():
|
| 14 |
+
return {"message": "API is running"}
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
@app.get("/materials")
|
| 18 |
+
def get_materials():
|
| 19 |
+
return JSONResponse(content=materials_data)
|