0

I'm new to django and trying to connect django with docker.
I'm trying to call docker compase from my django app using url. But I am receiving JSONDecodeError. I think my error is occured from these lines response = requests.get(url) output = response.json().
I'm having so much trouble about this issue.

How can I solve this error? Please, help.

views.py

def sentiment(request):
    output = {}
    if 'input' in request.GET:
        input = request.GET['input']
        url = 'http://localhost:5000/sentiment/%s' % input
        response = requests.get(url)
        output = response.json()
    return render(request, 'blog/links/Link1.html', {'output': output})

Link1.html

<form class="text" method="get" action="{% url 'da_sonuc'%}">
   <label for="textarea"> 
    <i class="fas fa-pencil-alt prefix"></i> Duygu Analizi 
  </label> 
     <h2>Test with your own text...</h2>
   <input class="input" type="text" name="input">
    <br>
   <button type="submit" class="btn" name="submit" >Try!</button>
</form>  
 <label > Result </label>
   <div class="outcome"> 
  {% if output %}
    <p><strong>{{ output.text }}</strong></p>
  {% endif %}
  </div>

Error:

 JSONDecodeError Expecting value: line 1 column 1 (char 0)
ilayda
  • 63
  • 1
  • 7
  • this might help you https://stackoverflow.com/questions/23013220/max-retries-exceeded-with-url-in-requests – DEEPAK KUMAR Apr 30 '21 at 20:51
  • I try a couple of things but it didn't solve my problem. I think it couldn't get a response. @DEEPAKKUMAR – ilayda Apr 30 '21 at 21:11

0 Answers0