title: Django "Internal Server Error" and "MultiValueDictKeyError" when calling external function
body: <p>I am running a django project on ubuntu that is supposed to build a website where I can</p>
  <ul>
  <li>upload an image</li>
  <li>run an external script to modify the image on click when uploaded</li>
  </ul>
  <p>The uploading process works fine, but when I try to run the external script I get an the  internal server error as seen below.</p>
  <p>Is this because of the added b' and \n in the path? If so, how can I solve that, please?</p>
  <p>Full Code can be found here <a href="https://github.com/hackanons/button-python-click/tree/master/Image%20Edit%20Html%20Button%20Run%20Python%20Script/buttonpython" rel="nofollow noreferrer">https://github.com/hackanons/button-python-click/tree/master/Image%20Edit%20Html%20Button%20Run%20Python%20Script/buttonpython</a></p>
  <p>Thanks a lot for help</p>
  <pre><code>image is  birdie1.png
  file raw url birdie1.png
  file full url /home/felix/ucmr/button-python-click/Image_Edit_Html_Button_Run_Python_Script/buttonpython/media/birdie1.png
  template url /media/birdie1.png
  CompletedProcess(args=['/home/felix/anaconda3/envs/ucmr/bin/python', '//home//felix//ucmr//button-python-click//Image_Edit_Html_Button_Run_Python_Script//test.py', 'upload'], returncode=0, stdout=b'Hi upload welcome to Hackanons &amp; time is 2021-06-01 20:35:53.229957\n')
  b'/media/temp.png\n'
  [01/Jun/2021 20:35:53] &quot;POST /external/ HTTP/1.1&quot; 200 1074
  [01/Jun/2021 20:35:53] &quot;GET /media/birdie1.png HTTP/1.1&quot; 200 103100
  Internal Server Error: /external/b'/media/temp.png/n'
  Traceback (most recent call last):
    File &quot;/home/felix/anaconda3/envs/ucmr/lib/python3.7/site-packages/django/utils/datastructures.py&quot;, line 78, in __getitem__
      list_ = super().__getitem__(key)
  KeyError: 'image'
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File &quot;/home/felix/anaconda3/envs/ucmr/lib/python3.7/site-packages/django/core/handlers/exception.py&quot;, line 34, in inner
      response = get_response(request)
    File &quot;/home/felix/anaconda3/envs/ucmr/lib/python3.7/site-packages/django/core/handlers/base.py&quot;, line 115, in _get_response
      response = self.process_exception_by_middleware(e, request)
    File &quot;/home/felix/anaconda3/envs/ucmr/lib/python3.7/site-packages/django/core/handlers/base.py&quot;, line 113, in _get_response
      response = wrapped_callback(request, *callback_args, **callback_kwargs)
    File &quot;/home/felix/ucmr/button-python-click/Image_Edit_Html_Button_Run_Python_Script/buttonpython/buttonpython/views.py&quot;, line 19, in external
      image=request.FILES['image']
    File &quot;/home/felix/anaconda3/envs/ucmr/lib/python3.7/site-packages/django/utils/datastructures.py&quot;, line 80, in __getitem__
      raise MultiValueDictKeyError(key)
  django.utils.datastructures.MultiValueDictKeyError: 'image'
  [01/Jun/2021 20:35:53] &quot;GET /external/b'/media/temp.png/n' HTTP/1.1&quot; 500 80417
  </code></pre>
  <p>views.py</p>
  <pre><code>from django.shortcuts import render
  import requests
  import sys
  from subprocess import run,PIPE
  from django.core.files.storage import FileSystemStorage
  
  def button(request):
  
      return render(request,'home.html')
  
  def output(request):
      data=requests.get(&quot;https://www.google.com/&quot;)
      print(data.text)
      data=data.text
      return render(request,'home.html',{'data':data})
  
  def external(request):
      inp=request.POST.get('param', False)
      image=request.FILES['image']
      print(&quot;image is &quot;,image)
      fs=FileSystemStorage()
      filename=fs.save(image.name, image)
      fileurl=fs.open(filename)
      templateurl=fs.url(filename)
      print(&quot;file raw url&quot;,filename)
      print(&quot;file full url&quot;, fileurl)
      print(&quot;template url&quot;,templateurl)
      out= run([sys.executable,'//home//felix//ucmr//button-python-click//Image_Edit_Html_Button_Run_Python_Script//test.py',inp],shell=False,stdout=PIPE)
      image= run([sys.executable,'//home//felix//ucmr//button-python-click//Image_Edit_Html_Button_Run_Python_Script//image.py',str(fileurl),str(filename)],shell=False,stdout=PIPE)
      print(out)
      print(image.stdout)
      return render(request,'home.html',{'data':out.stdout,'raw_url':templateurl,'edit_url':image.stdout})
  
  </code></pre>