Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomchristie/74f1ef35fa1ae6516ea81de704b3b421 to your computer and use it in GitHub Desktop.
Save tomchristie/74f1ef35fa1ae6516ea81de704b3b421 to your computer and use it in GitHub Desktop.
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