oguime
Posts: 19
Joined: Fri Feb 14, 2014 3:14 am

Built-in http server or framework

Wed Feb 26, 2014 11:43 am

I will use a Raspberry PI as a server to run python scripts from an ethernet connected Arduino (to encode short ip camera videos, send notifications through the internet and sync files to dropbox, for example).

Thinking about using Python's 3 http server to run the scripts as CGI, but would like to know what would be the advantages of running Flask, Web.py, Bottle or even Apache instead.

I would like to keep it as simple as possible, and even try to run AirPlay as a background process in the Pi, if possible.

Thanks!

User avatar
paddyg
Posts: 2317
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: Built-in http server or framework

Wed Feb 26, 2014 3:07 pm

I've just started a project where we have opted for Flask without really thinking through all the pros and cons... But it seems very easy to set up and use and it probably does quite a bit of the fiddly work for you (especially if security is even vaguely relevant). Using {{templates}} and clean urls might seem unnecessary for a simple app but it does speed up writing code.
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

oguime
Posts: 19
Joined: Fri Feb 14, 2014 3:14 am

Re: Built-in http server or framework

Wed Feb 26, 2014 9:10 pm

Do you see noticeable delays using Flask? Do you run concurrent tasks or heavy scripts?

Thanks

User avatar
paddyg
Posts: 2317
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: Built-in http server or framework

Wed Feb 26, 2014 9:45 pm

Subjectively it seems very fast over local wifi but I've not done any proper measurements yet, just skeleton system proving. Our set-up is raspberry pis connected via an offline wifi router with 'visitors' able to modify settings using a simple webpage. After initial loading there are just small json packages sent by ajax. Not running the x server. (I have had to start Flask using the mulitprocessing module as both it and the opengles functions need to run in the main thread, but I am more concerned that the server activity might cause pauses in the graphics in which case I will increase its niceness.)

I should have something a bit more integrated tomorrow and will be able to tell very quickly what impact Flask has on the graphics frame rate.
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

gkreidl
Posts: 5951
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Built-in http server or framework

Thu Feb 27, 2014 2:18 am

I'm running a Python server based on the Karrigell framework on my RPi. We did some speed tests a while ago, testing different kinds of dynamically created web pages; my contribution was the Python / Karrigell (multi threaded web server) test.
a) It serves about 35 dynamically created pages of about 4 KB per second.
b) For the same page as static html, it serves about 60 pages / sec.
c) With lighttpd serving the same static page I got 120 requests per second.

Overclocking:
a) and b): 1000/500 MHz
c) 900 / 450 MHz ( that was some time ago).

Testing done across a 100 MBit network with a simple Python script, retrieving one page after another, no parallel access.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

oguime
Posts: 19
Joined: Fri Feb 14, 2014 3:14 am

Re: Built-in http server or framework

Thu Feb 27, 2014 11:47 am

Your feedback is really welcome, thanks!

Just in case others are deciding on a framework, there is an extensive list at https://wiki.python.org/moin/WebFrameworks

Return to “Python”