Skip to content

Instantly share code, notes, and snippets.

@aaquirogal

aaquirogal/views.py

Last active Dec 7, 2017
Embed
What would you like to do?
Django authentication example - app/views.py
import requests
from django.contrib.auth.mixins import LoginRequiredMixin
from django.views.generic import TemplateView
class HomeView(TemplateView):
template_name = 'home.html'
def post(self, request, *args, **kwargs):
email = request.POST.get('email')
key = "BUSINESS-PREMIUM-DEMO-0mn3cblhl7hhfawjvrmr0a4r"
url = "http://api.pipl.com/search/?email={}.com&key={}".format(
email,
key,
)
response = requests.get(
url,
params={
'email': email,
'key': key,
},
)
string_response = response.content.decode("utf-8")
response_content = json.loads(string_response)
return self.render_to_response(
self.get_context_data(
response_content=response_content,
)
)
class DashboardView(LoginRequiredMixin, TemplateView):
template_name = 'dashboard.html'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment