Spaces:
Build error
Build error
Commit ·
d5fdbf3
1
Parent(s): fc60ff7
enchance
Browse files- README.md +1 -1
- app.py +0 -56
- requirements.txt +0 -4
README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
emoji: 💻
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: green
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Portal
|
| 3 |
emoji: 💻
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: green
|
app.py
DELETED
|
@@ -1,56 +0,0 @@
|
|
| 1 |
-
from fastapi import FastAPI
|
| 2 |
-
from fastapi.middleware.cors import CORSMiddleware
|
| 3 |
-
from fastapi.responses import JSONResponse
|
| 4 |
-
from fastapi.staticfiles import StaticFiles
|
| 5 |
-
import numpy as np
|
| 6 |
-
import argparse
|
| 7 |
-
import os
|
| 8 |
-
|
| 9 |
-
HOST = os.environ.get("API_URL", "0.0.0.0")
|
| 10 |
-
PORT = os.environ.get("PORT", 7860)
|
| 11 |
-
parser = argparse.ArgumentParser()
|
| 12 |
-
parser.add_argument("--host", default=HOST)
|
| 13 |
-
parser.add_argument("--port", type=int, default=PORT)
|
| 14 |
-
parser.add_argument("--reload", action="store_true", default=True)
|
| 15 |
-
parser.add_argument("--ssl_certfile")
|
| 16 |
-
parser.add_argument("--ssl_keyfile")
|
| 17 |
-
args = parser.parse_args()
|
| 18 |
-
|
| 19 |
-
app = FastAPI()
|
| 20 |
-
app.add_middleware(
|
| 21 |
-
CORSMiddleware,
|
| 22 |
-
allow_origins=["*"],
|
| 23 |
-
allow_credentials=True,
|
| 24 |
-
allow_methods=["*"],
|
| 25 |
-
allow_headers=["*"],
|
| 26 |
-
)
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
@app.get("/invert")
|
| 30 |
-
async def invert(text: str):
|
| 31 |
-
return {
|
| 32 |
-
"original": text,
|
| 33 |
-
"inverted": text[::-1],
|
| 34 |
-
}
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
@app.get("/data")
|
| 38 |
-
async def get_data():
|
| 39 |
-
data = {"data": np.random.rand(100).tolist()}
|
| 40 |
-
return JSONResponse(data)
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
app.mount("/", StaticFiles(directory="static", html=True), name="static")
|
| 44 |
-
|
| 45 |
-
if __name__ == "__main__":
|
| 46 |
-
import uvicorn
|
| 47 |
-
|
| 48 |
-
print(args)
|
| 49 |
-
uvicorn.run(
|
| 50 |
-
"app:app",
|
| 51 |
-
host=args.host,
|
| 52 |
-
port=args.port,
|
| 53 |
-
reload=args.reload,
|
| 54 |
-
ssl_certfile=args.ssl_certfile,
|
| 55 |
-
ssl_keyfile=args.ssl_keyfile,
|
| 56 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
requirements.txt
DELETED
|
@@ -1,4 +0,0 @@
|
|
| 1 |
-
fastapi==0.104.*
|
| 2 |
-
torch==2.1.*
|
| 3 |
-
transformers==4.*
|
| 4 |
-
uvicorn[standard]==0.24.*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|