Spaces:
Runtime error
Runtime error
Commit
•
bd149ab
1
Parent(s):
3be5866
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastapi.middleware.cors import CORSMiddleware
|
2 |
+
from fastapi.responses import JSONResponse
|
3 |
+
from fastapi import FastAPI
|
4 |
+
import json
|
5 |
+
|
6 |
+
app = FastAPI()
|
7 |
+
|
8 |
+
app.add_middleware(CORSMiddleware, allow_origins = ['*'], allow_credentials = True, allow_methods = ['*'], allow_headers = ['*'])
|
9 |
+
|
10 |
+
@app.get('/')
|
11 |
+
def index():
|
12 |
+
|
13 |
+
return JSONResponse(status_code = 200, content = {'status' : 'online'})
|
14 |
+
|
15 |
+
@app.get('/read')
|
16 |
+
def read_route():
|
17 |
+
|
18 |
+
with open('cookies.json', 'r', encoding = 'utf-8') as file:
|
19 |
+
|
20 |
+
data = json.load(file)
|
21 |
+
|
22 |
+
return JSONResponse(status_code = 200, content = data)
|