Created
          June 22, 2018 11:58 
        
      - 
      
- 
        Save jerzyk/ea5de8d288a2d5384a17c866265bb829 to your computer and use it in GitHub Desktop. 
    aoi proxy
  
        
  
    
      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 characters
    
  
  
    
  | #!/usr/bin/env python | |
| import aiohttp | |
| import asyncio | |
| from aiojobs.aiohttp import setup, spawn | |
| from aiohttp import web | |
| async def coro(address): | |
| async with aiohttp.ClientSession() as session: | |
| async with session.get(address) as resp: | |
| return await resp.text() | |
| async def index(request): | |
| data = await request.post() | |
| addr = data.get('address') | |
| if addr: | |
| job = await spawn(request, coro(addr)) | |
| response = await job.wait() | |
| return web.Response(text=response) | |
| else: | |
| raise web.HTTPBadRequest() | |
| app = web.Application() | |
| app.add_routes([web.post('/', index)]) | |
| setup(app) | |
| web.run_app(app) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment