Arduino yun uhttpd flask setup

I am trying to configure python and flask on arduino yun. I managed to run python files through the / etc / config / uhttpd configuration file:

...
list interpreter    ".py=/usr/bin/python"
...

The default path for the root site of the website is / www, in which I placed the soft link (s) on the SD card. So now I can run python programs: http: // [ip arduino] /apps/helloworld.py

And when I make my first program helloflask.py and run it through python helloflask.py, I can see the result at: http: // [ip arduino]: 5000

But now I want to configure the uhttpd mini web server (which is able to exchange information via CGI) to use the flask configuration. URI: http://flask.pocoo.org/docs/deploying/cgi/#server-setup shows some instructions ... but I just don't understand. I created a .. / apps / uno directory in which I placed the __init__.py file with the following contents:

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
    return "He Flask!"   

In the application directory, I put the cgi.py file with this content:

from wsgiref.handlers import CGIHandler
from uno import app

CGIHandler().run(app)

Now when I look: http: // [ip arduino] /cgi.py to get a server error, contact the administrator (I think this is the CGI interface from uhttpd).

I just don't understand the CGI configuration for Flask / uhttpd

+3
source share
1 answer

, , , - , , uhttpd / URL. , URL- .py , , http://(arduino IP)/flaskapp/. .

, uhttpd, , , . , , Yun: https://learn.adafruit.com/smart-measuring-cup/overview

, app.run script, , - :

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello Flask!"

if __name__ == '__main__':
    app.run(host='0.0.0.0', debug=True, threaded=True)

Yun script python. , , http://(arduino IP): 5000/. = '0.0.0.0', Yun. , debug = True, ( ), threaded = True, . Yun - , , REST API - .

, , /etc/rc.local, python script.

+1

All Articles