shashidharak99 commited on
Commit
f7d012e
·
verified ·
1 Parent(s): 31bc0d4

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
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)