Created
June 15, 2018 09:26
-
-
Save tomchristie/74f1ef35fa1ae6516ea81de704b3b421 to your computer and use it in GitHub Desktop.
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
import aiohttp | |
from django.views.generic import TemplateView | |
class FetchView(TemplateView): | |
template_name = 'index.html' | |
async def get(self, request, *args, **kwargs): | |
async with aiohttp.ClientSession() as session: | |
async with session.get(url) as response: | |
response_text = await response.text() | |
return self.render_to_response({'response_text': response_text}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment