Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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