Answers for "read api from django"

0

read api from django

from django.shortcuts import render
import requests

def github(request):
    user = {}
    if 'username' in request.GET:
        username = request.GET['username']
        url = 'https://api.github.com/users/%s' % username
        response = requests.get(url)
        user = response.json()
    return render(request, 'core/github.html', {'user': user})
Posted by: Guest on August-04-2021

Python Answers by Framework

Browse Popular Code Answers by Language