Download main.py from kenton-li/record: direct link, hf CLI and curl.
- Browser
- Download file 966 Bytes
-
https://huggingface.co/spaces/kenton-li/record/resolve/main/main.py
- Command line
-
hf download hf://spaces/kenton-li/record/main.py
-
curl -L -o main.py https://huggingface.co/spaces/kenton-li/record/resolve/main/main.py
966 Bytes
| from fastapi import FastAPI, Request | |
| from fastapi.responses import Response | |
| import httpx | |
| app = FastAPI() | |
| async def proxy(request: Request, path: str): | |
| target_url = f"http://216.128.139.239:5000/{path}" | |
| async with httpx.AsyncClient() as client: | |
| method = request.method | |
| headers = dict(request.headers) | |
| params = request.query_params | |
| content = await request.body() | |
| response = await client.request( | |
| method=method, | |
| url=target_url, | |
| headers=headers, | |
| params=params, | |
| content=content | |
| ) | |
| return Response( | |
| content=response.content, | |
| status_code=response.status_code, | |
| headers=dict(response.headers) | |
| ) | |
| if __name__ == "__main__": | |
| import os | |
| os.system("uvicorn main:app --host 0.0.0.0 --port 7860") | |