|
import aiohttp |
|
from aiohttp import web |
|
|
|
async def proxy_handler(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: |
|
|
|
async with session.request(method, url, headers=headers, data=data) as response: |
|
|
|
content = await response.read() |
|
|
|
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) |