Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal Server Error: /external/b'/media/temp.png/n' #3

Open
felixboevr opened this issue Jun 1, 2021 · 1 comment
Open

Internal Server Error: /external/b'/media/temp.png/n' #3

felixboevr opened this issue Jun 1, 2021 · 1 comment

Comments

@felixboevr
Copy link

Hi @hackanons
thanks for your great project. I tried to run "Image Edit Html Button Run Python Script" on Ubuntu/Linux and everything almost works fine but I get the following error which seems to be caused by the wrong path output. Could you please have a look at it. Any help would be great.

[01/Jun/2021 23:13:47] "GET / HTTP/1.1" 200 763
Not Found: /favicon.ico
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 & time is 2021-06-01 23:13:54.782867\n')
b'/media/temp.png\n'
[01/Jun/2021 23:13:54] "POST /external/ HTTP/1.1" 200 1074
[01/Jun/2021 23:13:54] "GET /media/birdie1.png HTTP/1.1" 200 103100
Internal Server Error: /external/b'/media/temp.png/n'
Traceback (most recent call last):
  File "/home/felix/anaconda3/envs/ucmr/lib/python3.7/site-packages/django/utils/datastructures.py", 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 "/home/felix/anaconda3/envs/ucmr/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/felix/anaconda3/envs/ucmr/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/felix/anaconda3/envs/ucmr/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/felix/ucmr/button-python-click/Image_Edit_Html_Button_Run_Python_Script/buttonpython/buttonpython/views.py", line 19, in external
    image=request.FILES['image']
  File "/home/felix/anaconda3/envs/ucmr/lib/python3.7/site-packages/django/utils/datastructures.py", line 80, in __getitem__
    raise MultiValueDictKeyError(key)
django.utils.datastructures.MultiValueDictKeyError: 'image'
[01/Jun/2021 23:13:54] "GET /external/b'/media/temp.png/n' HTTP/1.1" 500 80443
@felixboevr
Copy link
Author

The error

Internal Server Error: /external/b'/media/temp.png/n'

was caused by the corrupted path above from the stdout Process. I added "universal_newlines=True" from subprocess module to stdout and everything works fine.

    out= run([sys.executable,'//home//felix//ucmr//button-python-click//Image_Edit_Html_Button_Run_Python_Script//test.py',inp],shell=False,stdout=PIPE,universal_newlines=True)
    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,universal_newlines=True)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant