Spaces:
Runtime error
Runtime error
| import os | |
| from gradio import Server | |
| from fastapi.responses import HTMLResponse, FileResponse | |
| from fastapi.staticfiles import StaticFiles | |
| app = Server(title="Heartline ") | |
| _here = os.path.dirname(os.path.abspath(__file__)) | |
| app.mount("/samples", StaticFiles(directory=os.path.join(_here, "samples")), name="samples") | |
| async def serve_model() -> FileResponse: | |
| path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "heartline.onnx") | |
| return FileResponse(path, media_type="application/octet-stream") | |
| async def serve_constants() -> FileResponse: | |
| path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "constants.js") | |
| return FileResponse(path, media_type="application/javascript") | |
| async def serve_gguf() -> FileResponse: | |
| path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "model_Q4_K_M.gguf") | |
| return FileResponse(path, media_type="application/octet-stream") | |
| async def homepage() -> HTMLResponse: | |
| path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "index.html") | |
| with open(path, "r", encoding="utf-8") as f: | |
| return HTMLResponse(f.read()) | |
| app.launch(server_name="0.0.0.0", server_port=7860, show_error=True, _frontend=False) | |