Spaces:
Runtime error
Runtime error
Update main.py
Browse files
main.py
CHANGED
@@ -2,18 +2,29 @@ from fastapi import FastAPI, File, UploadFile
|
|
2 |
from fastapi.responses import StreamingResponse
|
3 |
import os
|
4 |
import io
|
5 |
-
|
6 |
-
temp.write("aaaaaaaaaaaaa")
|
7 |
-
temp.close()
|
8 |
-
|
9 |
-
temp = open("t.txt","r")
|
10 |
|
11 |
app = FastAPI()
|
12 |
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
|
16 |
-
@app.get("/
|
17 |
def read_root():
|
18 |
-
return {"message":
|
19 |
|
|
|
2 |
from fastapi.responses import StreamingResponse
|
3 |
import os
|
4 |
import io
|
5 |
+
import requests
|
|
|
|
|
|
|
|
|
6 |
|
7 |
app = FastAPI()
|
8 |
|
9 |
|
10 |
+
@app.on_event("startup")
|
11 |
+
@repeat_every(seconds=60 * 10) # 1 hour
|
12 |
+
def refresh_the_api():
|
13 |
+
|
14 |
+
url = "https://research-project-h4fb.onrender.com/refresh_api"
|
15 |
+
|
16 |
+
payload = {}
|
17 |
+
headers = {
|
18 |
+
'accept': 'application/json'
|
19 |
+
}
|
20 |
+
|
21 |
+
response = requests.request("POST", url, headers=headers, data=payload)
|
22 |
+
|
23 |
+
print(response.text)
|
24 |
+
return response.text
|
25 |
|
26 |
|
27 |
+
@app.get("/test")
|
28 |
def read_root():
|
29 |
+
return {"message":"running"}
|
30 |
|