Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -61,6 +61,41 @@ async def _():
|
|
61 |
async def _():
|
62 |
return RedirectResponse("https://huggingface.co/oauth/register")
|
63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
if __name__ == "__main__":
|
66 |
import uvicorn
|
|
|
61 |
async def _():
|
62 |
return RedirectResponse("https://huggingface.co/oauth/register")
|
63 |
|
64 |
+
@app.post("/register")
|
65 |
+
async def register_proxy(request: Request):
|
66 |
+
"""Forward requests to Hugging Face OAuth register endpoint"""
|
67 |
+
target_url = "https://huggingface.co/oauth/register"
|
68 |
+
|
69 |
+
async with httpx.AsyncClient() as client:
|
70 |
+
# Prepare the request data
|
71 |
+
headers = dict(request.headers)
|
72 |
+
# Remove host header to avoid conflicts
|
73 |
+
headers.pop("host", None)
|
74 |
+
|
75 |
+
# Get query parameters
|
76 |
+
query_params = str(request.url.query) if request.url.query else None
|
77 |
+
target_url_with_params = f"{target_url}?{query_params}" if query_params else target_url
|
78 |
+
|
79 |
+
# Get request body if present
|
80 |
+
body = await request.body()
|
81 |
+
|
82 |
+
print("body", body)
|
83 |
+
|
84 |
+
# Forward the request
|
85 |
+
response = await client.request(
|
86 |
+
method=request.method,
|
87 |
+
url=target_url_with_params,
|
88 |
+
headers=headers,
|
89 |
+
content=body,
|
90 |
+
follow_redirects=False
|
91 |
+
)
|
92 |
+
|
93 |
+
# Return the response with the same status code, headers, and content
|
94 |
+
return Response(
|
95 |
+
content=response.content,
|
96 |
+
status_code=response.status_code,
|
97 |
+
headers=dict(response.headers)
|
98 |
+
)
|
99 |
|
100 |
if __name__ == "__main__":
|
101 |
import uvicorn
|