Connection error while using requests module in my django project

I was trying to create a django project. Everything was fine until I did a get request using requests.get() in python in my views.py

Following is what my views.py have

from django.http import HttpResponse
from django.shortcuts import render
import re, requests

def codify_data(data_raw):
    data = data_raw.json()['data']
    if language == 'web':
        html_cd = data['sourceCode']
        css_cd = data['cssCode']
        js_cd = data['jsCode']

def home_page(request):
    return render(request,'home/index.html')
    
def code(request):
    link = request.GET.get('link', 'https://code.sololearn.com/c5I5H9T7viyb/?ref=app')
    
    result = re.search(r'https://code.sololearn.com/(.*)/?ref=app',link).group(1)[0:-2]
    data_raw = requests.get('https://api2.sololearn.com/v2/codeplayground/usercodes/'+result)
    codify_data(data_raw)

The error is shown below:

image

Back to Top