/* jquery */ /* jquery accordion style*/ /* jquery init */

BottlePy Web Server on a Raspberry Pi

The flexibility of the Raspberry Pi means it can host a number of popular web servers. But they can be rather large and complex and therefore a little intimidating.

So, would you rather have a tiny, fast and lightweight server that implemented entirely in Python?

One of the easiest ways to get started is with Bottle.

All you'll need to do is download and install the module, then write some code.

The simplest code example is the classic 'Hello World' as below (taken from the Bottle website):

from bottle import route, run

@route('/hello')
def hello():
   return "Hello World!"

run(host='localhost', port=8080, debug=True)

To test the above code:
  (a) execute the Python program
  (b) point your browser to http://localhost:8080/hello.

More Raspberry Pi Python Coding Tutorials

No comments: