Spaces:
Running
Running
Download main.py from michaelj/FastAPI_lcm_docker: direct link, hf CLI and curl.
- Browser
- Download file 703 Bytes
-
https://huggingface.co/spaces/michaelj/FastAPI_lcm_docker/resolve/e07c4e98e13e473c440bb07d58bd289bf0c1bdad/main.py
- Command line
-
hf download hf://spaces/michaelj/FastAPI_lcm_docker@e07c4e98e13e473c440bb07d58bd289bf0c1bdad/main.py
-
curl -L -o main.py https://huggingface.co/spaces/michaelj/FastAPI_lcm_docker/resolve/e07c4e98e13e473c440bb07d58bd289bf0c1bdad/main.py
703 Bytes
| # https://medium.com/@qacheampong/building-and-deploying-a-fastapi-app-with-hugging-face-9210e9b4a713 | |
| # https://huggingface.co/spaces/Queensly/FastAPI_in_Docker | |
| from fastapi import FastAPI,Request | |
| import uvicorn | |
| import json | |
| app = FastAPI() | |
| #Endpoints | |
| #Root endpoints | |
| def root(): | |
| return {"API": "Sum of 2 Squares"} | |
| async def predict(url:str,prompt:str): | |
| body = await request.body() | |
| data = json.loads(body) | |
| prompt = data.get("prompt") | |
| return f"您好,{url+prompt}" | |
| async def predict(request:Request): | |
| body = await request.body() | |
| data = json.loads(body) | |
| prompt = data.get("prompt") | |
| return f"您好,{prompt}" | |