Spaces:
Paused
Paused
Update main.py
Browse files
main.py
CHANGED
|
@@ -49,6 +49,15 @@ def inference(img_path, Style, if_face=None):
|
|
| 49 |
except Exception as error:
|
| 50 |
print('global exception', error)
|
| 51 |
return None, None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
|
| 54 |
@app.post("/inference/")
|
|
@@ -65,8 +74,3 @@ async def inference_api(file: UploadFile = File(...), Style: str = Form(...), if
|
|
| 65 |
except Exception as e:
|
| 66 |
return {"error": str(e)}
|
| 67 |
|
| 68 |
-
app.mount("/", StaticFiles(directory="static", html=True), name="static")
|
| 69 |
-
|
| 70 |
-
@app.get("/")
|
| 71 |
-
def index() -> FileResponse:
|
| 72 |
-
return FileResponse(path="/app/static/index.html", media_type="text/html")
|
|
|
|
| 49 |
except Exception as error:
|
| 50 |
print('global exception', error)
|
| 51 |
return None, None
|
| 52 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 53 |
+
|
| 54 |
+
app.add_middleware(
|
| 55 |
+
CORSMiddleware,
|
| 56 |
+
allow_origins=["*"], # Adjust as needed, '*' allows requests from any origin
|
| 57 |
+
allow_credentials=True,
|
| 58 |
+
allow_methods=["*"],
|
| 59 |
+
allow_headers=["*"],
|
| 60 |
+
)
|
| 61 |
|
| 62 |
|
| 63 |
@app.post("/inference/")
|
|
|
|
| 74 |
except Exception as e:
|
| 75 |
return {"error": str(e)}
|
| 76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|