ldrlwr / app.py
ewftrhyjk's picture
Update app.py
725c615 verified
raw
history blame
828 Bytes
import aiohttp
from aiohttp import web
async def proxy_handler(request):
# Extract request parameters from user's request
method = request.method
url = "https://api.telegram.org" + request.path_qs
headers = request.headers
data = await request.read()
async with aiohttp.ClientSession() as session:
# Make a request to the Telegram API
async with session.request(method, url, headers=headers, data=data) as response:
# Get response content
content = await response.read()
# Forward response from Telegram API to user
return web.Response(body=content, status=response.status, headers=response.headers)
app = web.Application()
app.router.add_route('*', '/{path:.*}', proxy_handler)
if __name__ == '__main__':
web.run_app(app,port=7860)