Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI,Request,HTTPException,Response
|
| 2 |
+
from pydantic import BaseModel
|
| 3 |
+
from fastapi.responses import JSONResponse
|
| 4 |
+
import uuid
|
| 5 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 6 |
+
import json
|
| 7 |
+
import base64
|
| 8 |
+
from components.middleware import x401Kit
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
app=FastAPI()
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
origins=["*"]
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
app.add_middleware(
|
| 22 |
+
CORSMiddleware,
|
| 23 |
+
allow_origins=origins,
|
| 24 |
+
allow_credentials=True,
|
| 25 |
+
allow_methods=["*"],
|
| 26 |
+
allow_headers=["*"],
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
app.add_middleware(
|
| 33 |
+
x401Kit,
|
| 34 |
+
protected_paths=[
|
| 35 |
+
"/x401_auth_agent"
|
| 36 |
+
]
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
@app.get("/x401_auth_agent")
|
| 42 |
+
def Auth401(request:Request):
|
| 43 |
+
return {"token":""}
|