Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -5,14 +5,20 @@ import threading
|
|
5 |
import time
|
6 |
|
7 |
from fastapi import FastAPI
|
8 |
-
from
|
9 |
-
from typing import ClassVar
|
10 |
-
|
11 |
-
class Settings(BaseModel):
|
12 |
-
arbitrary_types_allowed: ClassVar[bool] = True
|
13 |
|
14 |
app = FastAPI()
|
15 |
-
app.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
|
18 |
# ๋ก๊น
์ค์
|
@@ -145,7 +151,6 @@ def periodic_update(status_html):
|
|
145 |
new_status = update_status()
|
146 |
status_html.update(value=new_status)
|
147 |
|
148 |
-
# Gradio ์ธํฐํ์ด์ค ์ค์
|
149 |
def create_dashboard():
|
150 |
with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as app:
|
151 |
gr.Image("banner.png", show_label=False)
|
@@ -163,8 +168,10 @@ def create_dashboard():
|
|
163 |
# ๋ฐฑ๊ทธ๋ผ์ด๋์์ ์ฃผ๊ธฐ์ ์
๋ฐ์ดํธ ์์
|
164 |
threading.Thread(target=periodic_update, args=(status_html,), daemon=True).start()
|
165 |
|
|
|
166 |
return app
|
167 |
|
|
|
168 |
if __name__ == "__main__":
|
169 |
dashboard = create_dashboard()
|
170 |
dashboard.launch()
|
|
|
5 |
import time
|
6 |
|
7 |
from fastapi import FastAPI
|
8 |
+
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
|
|
|
|
|
9 |
|
10 |
app = FastAPI()
|
11 |
+
app.add_middleware(
|
12 |
+
CORSMiddleware,
|
13 |
+
allow_origins=["*"],
|
14 |
+
allow_credentials=True,
|
15 |
+
allow_methods=["*"],
|
16 |
+
allow_headers=["*"],
|
17 |
+
)
|
18 |
+
|
19 |
+
@app.on_event("startup")
|
20 |
+
async def startup_event():
|
21 |
+
app.state.arbitrary_types_allowed = True
|
22 |
|
23 |
|
24 |
# ๋ก๊น
์ค์
|
|
|
151 |
new_status = update_status()
|
152 |
status_html.update(value=new_status)
|
153 |
|
|
|
154 |
def create_dashboard():
|
155 |
with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as app:
|
156 |
gr.Image("banner.png", show_label=False)
|
|
|
168 |
# ๋ฐฑ๊ทธ๋ผ์ด๋์์ ์ฃผ๊ธฐ์ ์
๋ฐ์ดํธ ์์
|
169 |
threading.Thread(target=periodic_update, args=(status_html,), daemon=True).start()
|
170 |
|
171 |
+
pass
|
172 |
return app
|
173 |
|
174 |
+
|
175 |
if __name__ == "__main__":
|
176 |
dashboard = create_dashboard()
|
177 |
dashboard.launch()
|