Database Reference
In-Depth Information
Bottle Web Framework for Python
Bottle
is a Python implementation of what is often called a
micro framework
. The aim of a micro framework is to help
you quickly build out powerful web applications and APIs only using what is absolutely necessary to get the job done.
Bottle is fast, simple, and lightweight and uses the Python specification known as the
Web Server Gateway
Interface
. It is distributed as a single file module and has no dependencies other than the Python Standard Library.
As you can see in Listing 9-1, the code required for processing a request and providing a response is fairly limited.
■
Bottle is maintained by the Python dev Marcel Hellkamp and supported by a number of equally outstanding
Note
Listing 9-1.
Bottle Example of GET Route
from bottle import route, template
# home page
@route('/')
def index():
return template("public/templates/home/index.html", title="Home")
Local Apache Configuration
To follow the sample application found later in this chapter, you will need to properly configure your local Apache
webserver to use the workspace project in Eclipse as the document root. One way to accomplish this is adding a
virtual host to Apache. Listing 9-2 covers the basic configuration for adding a virtual host to the httpd-vhosts.conf file.
■
If you do not have Apache HTTP installed, go to
http://httpd.apache.org/
and follow the instructions
based on your operating system. Configuring Python with a local instance of Apache HTTP is out of the scope of this topic,
Important
Listing 9-2.
Minimum Configuration for
httpd-vhosts.conf
NameVirtualHost *:80
<VirtualHost *:80>
ServerName practicalneo4j-python
DocumentRoot /path/to/your/workspace/practicalneo4j-python/app/public
<Directory /path/to/your/workspace/practicalneo4j-python/app/public>
Options None
AllowOverride None
Order allow,deny
allow from all
</Directory>
WSGIDaemonProcess graphstory user=_www group=_www processes=1 threads=15
WSGIProcessGroup graphstory