Spaces:
Runtime error
Runtime error
Download app.py from AntonyManojXavier/TestSpace: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/spaces/AntonyManojXavier/TestSpace/resolve/main/app.py
- Command line
-
hf download hf://spaces/AntonyManojXavier/TestSpace/app.py
-
curl -L -o app.py https://huggingface.co/spaces/AntonyManojXavier/TestSpace/resolve/main/app.py
1.04 kB
| import gradio as gr | |
| from processing import process_file | |
| from models import ModifiedGCN | |
| from fastapi import FastAPI, File, UploadFile | |
| from fastapi.responses import JSONResponse | |
| import uvicorn | |
| app = FastAPI() | |
| def process_file_wrapper(file_path): | |
| status, file = process_file(file_path) | |
| return status, file | |
| async def predict(file: UploadFile = File(...)): | |
| contents = await file.read() | |
| file_path = "uploaded_file.json" | |
| with open(file_path, "wb") as f: | |
| f.write(contents) | |
| status, processed_file = process_file_wrapper(file_path) | |
| return JSONResponse(content={"status": status, "file": processed_file}) | |
| def gradio_interface(): | |
| iface = gr.Interface( | |
| fn=process_file_wrapper, | |
| inputs=gr.File(label="Upload your file"), | |
| outputs=[gr.Textbox(label="Status"), gr.File(label="Download the file")] | |
| ) | |
| iface.launch(server_name="0.0.0.0", server_port=7860) | |
| if __name__ == "__main__": | |
| gradio_interface() | |
| uvicorn.run(app, host="0.0.0.0", port=7860) |