Spaces:
Sleeping
Sleeping
kumahiyo
commited on
Commit
•
98fc1c9
1
Parent(s):
4f9ea63
add check data
Browse files
main.py
CHANGED
@@ -1,8 +1,21 @@
|
|
1 |
from fastapi import FastAPI
|
2 |
from fastapi.staticfiles import StaticFiles
|
|
|
|
|
3 |
|
4 |
app = FastAPI()
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
@app.get("/")
|
7 |
def index():
|
8 |
-
|
|
|
|
|
|
|
|
1 |
from fastapi import FastAPI
|
2 |
from fastapi.staticfiles import StaticFiles
|
3 |
+
from pydantic import BaseModel
|
4 |
+
from pydantic import Field
|
5 |
|
6 |
app = FastAPI()
|
7 |
|
8 |
+
class Data(BaseModel):
|
9 |
+
string: str
|
10 |
+
member_secret: str
|
11 |
+
|
12 |
+
class ItemOut(BaseModel):
|
13 |
+
status: str
|
14 |
+
file: str
|
15 |
+
|
16 |
@app.get("/")
|
17 |
def index():
|
18 |
+
if data.member_secret != "" and data.member_secret == os.environ.get("MEMBER_SECRET"):
|
19 |
+
return {"status": "OK", "file": "hello world!"}
|
20 |
+
else:
|
21 |
+
return {"status": "SORRY! This file is member only.", "file": ""}
|