Error upon executing http get

55 views
Skip to first unread message

Shawn Bashir

unread,
Jul 5, 2020, 8:54:45 PM7/5/20
to sucks-users
Hi.

First of all, excellent work on this! I've managed to get most of it setup, and was able to get things like 'sucks clean 10' to work, however, seem to get errors when trying to do an http get. 

I did the export of the variable:

pi@raspberrypi:~ $ export FLASK_APP=/home/pi/Documents/sucksScripts/clean120charge.py


I then got the flash server up and running with the following confirmation:

pi@raspberrypi:~ $ flask run --host=192.168.2.56
 
* Serving Flask app "/home/pi/Documents/sucksScripts/clean120charge.py"
 
* Environment: production
   WARNING
: Do not use the development server in a production environment.
   
Use a production WSGI server instead.
 
* Debug mode: off
 
* Running on http://192.168.2.56:5000/ (Press CTRL+C to quit)


The contents of the clean120charge.py script is the following:

from flask import Flask


import subprocess


app
= Flask(__name__)


@app.route('/')


def my_command():


    cmd
= ["sucks clean 120 charge"]


    p
= subprocess.Popen(cmd)


   
return


if __name__ == "__main__" :


    app
.run()

See below for the http get and error print:

pi@raspberrypi:~ $ curl http://192.168.2.56:5000/
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>500 Internal Server Error</title>
<h1>Internal Server Error</
h1>
<p>The server encountered an internal error and was unable to complete your request.  Either the server is overloaded or there is an error in the application.</p>


See below for the prints on the server terminal (separate instance):

pi@raspberrypi:~ $ flask run --host=192.168.2.56
 
* Serving Flask app "/home/pi/Documents/sucksScripts/clean120charge.py"
 
* Environment: production
   WARNING
: Do not use the development server in a production environment.
   
Use a production WSGI server instead.
 
* Debug mode: off
 
* Running on http://192.168.2.56:5000/ (Press CTRL+C to quit)
[2020-07-05 20:42:48,033] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
 
File "/usr/lib/python3/dist-packages/flask/app.py", line 2292, in wsgi_app
    response
= self.full_dispatch_request()
 
File "/usr/lib/python3/dist-packages/flask/app.py", line 1815, in full_dispatch_request
    rv
= self.handle_user_exception(e)
 
File "/usr/lib/python3/dist-packages/flask/app.py", line 1718, in handle_user_exception
    reraise
(exc_type, exc_value, tb)
 
File "/usr/lib/python3/dist-packages/flask/_compat.py", line 35, in reraise
   
raise value
 
File "/usr/lib/python3/dist-packages/flask/app.py", line 1813, in full_dispatch_request
    rv
= self.dispatch_request()
 
File "/usr/lib/python3/dist-packages/flask/app.py", line 1799, in dispatch_request
   
return self.view_functions[rule.endpoint](**req.view_args)
 
File "/home/pi/Documents/sucksScripts/clean120charge.py", line 13, in my_command
    p
= subprocess.Popen(cmd)
 
File "/usr/lib/python3.7/subprocess.py", line 775, in __init__
    restore_signals
, start_new_session)
 
File "/usr/lib/python3.7/subprocess.py", line 1522, in _execute_child
   
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'sucks clean 120 charge': 'sucks clean 120 charge'
192.168.2.56 - - [05/Jul/2020 20:42:48] "GET / HTTP/1.1" 500 -

It seems like it would be a trivial error however I'm not quite sure how to debug it. Any chance your can provide some insight?

Thank you in advance!

Reply all
Reply to author
Forward
0 new messages