Created
January 16, 2024 20:31
-
-
Save drizzt/93d253bca4f64fae7df2a4544a98c08d to your computer and use it in GitHub Desktop.
Revisions
-
drizzt revised this gist
Jan 16, 2024 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -30,7 +30,6 @@ async def topic(request): app = Starlette( routes=[ Route("/{path:path}", topic, methods=["PUT"]), ], -
drizzt created this gist
Jan 16, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ #!/usr/bin/python3 import uvloop uvloop.install() from starlette.applications import Starlette from starlette.responses import Response from starlette.routing import Route import httpx async def topic(request): path = request.path_params["path"] body = await request.body() # Forward the request to the target URL async with httpx.AsyncClient() as client: upstream_response = await client.post( url=path, data=body, ) return Response( content=upstream_response.content, status_code=upstream_response.status_code ) app = Starlette( debug=True, routes=[ Route("/{path:path}", topic, methods=["PUT"]), ], )