Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -312,6 +312,26 @@ from starlette.middleware.cors import CORSMiddleware
|
|
| 312 |
# Define the FastAPI app
|
| 313 |
app = FastAPI()
|
| 314 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 315 |
# Define paths for static files
|
| 316 |
app.mount("/static", StaticFiles(directory="."), name="static")
|
| 317 |
|
|
@@ -377,7 +397,7 @@ about_html = f'''
|
|
| 377 |
|
| 378 |
|
| 379 |
# Mount Gradio app
|
| 380 |
-
app = gr.mount_gradio_app(app, demo, path="/gradioapp"
|
| 381 |
|
| 382 |
# Define the route for the main page
|
| 383 |
@app.get("/", response_class=HTMLResponse)
|
|
@@ -388,6 +408,7 @@ async def index():
|
|
| 388 |
@app.get("/about", response_class=HTMLResponse)
|
| 389 |
async def about():
|
| 390 |
return about_html
|
|
|
|
| 391 |
# serve the app
|
| 392 |
if __name__ == "__main__":
|
| 393 |
uvicorn.run(app, host="0.0.0.0", port=7860)
|
|
|
|
| 312 |
# Define the FastAPI app
|
| 313 |
app = FastAPI()
|
| 314 |
|
| 315 |
+
# @app.middleware("http")
|
| 316 |
+
# async def add_csp_header(request, call_next):
|
| 317 |
+
# response = await call_next(request)
|
| 318 |
+
# response.headers['Content-Security-Policy'] = "frame-ancestors 'self' https://*.azurewebsites.net"
|
| 319 |
+
# return response
|
| 320 |
+
|
| 321 |
+
# @app.middleware("https")
|
| 322 |
+
# async def add_csp_header(request, call_next):
|
| 323 |
+
# response = await call_next(request)
|
| 324 |
+
# response.headers['Content-Security-Policy'] = "frame-ancestors 'self' https://*.azurewebsites.net"
|
| 325 |
+
# return response
|
| 326 |
+
|
| 327 |
+
# app.add_middleware(
|
| 328 |
+
# CORSMiddleware,
|
| 329 |
+
# allow_origins=["*"], # Adjust this in production
|
| 330 |
+
# allow_credentials=True,
|
| 331 |
+
# allow_methods=["*"],
|
| 332 |
+
# allow_headers=["*"],
|
| 333 |
+
# )
|
| 334 |
+
|
| 335 |
# Define paths for static files
|
| 336 |
app.mount("/static", StaticFiles(directory="."), name="static")
|
| 337 |
|
|
|
|
| 397 |
|
| 398 |
|
| 399 |
# Mount Gradio app
|
| 400 |
+
app = gr.mount_gradio_app(app, demo, path="/gradioapp")#, allowed_paths=["/"], root_path="deploy/")
|
| 401 |
|
| 402 |
# Define the route for the main page
|
| 403 |
@app.get("/", response_class=HTMLResponse)
|
|
|
|
| 408 |
@app.get("/about", response_class=HTMLResponse)
|
| 409 |
async def about():
|
| 410 |
return about_html
|
| 411 |
+
|
| 412 |
# serve the app
|
| 413 |
if __name__ == "__main__":
|
| 414 |
uvicorn.run(app, host="0.0.0.0", port=7860)
|