seawolf2357 commited on
Commit
6705a11
ยท
verified ยท
1 Parent(s): 1223c0d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -7
app.py CHANGED
@@ -5,14 +5,20 @@ import threading
5
  import time
6
 
7
  from fastapi import FastAPI
8
- from pydantic import BaseModel
9
- from typing import ClassVar
10
-
11
- class Settings(BaseModel):
12
- arbitrary_types_allowed: ClassVar[bool] = True
13
 
14
  app = FastAPI()
15
- app.config = Settings()
 
 
 
 
 
 
 
 
 
 
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()