lundi 27 janvier 2014

[Bottle + Tornado] From a Bottle application, sending parameters to the Tornado server

When you use Bottle + Tornado (or CherryPy,... etc...), you can give options to the Tornado server, by declaring them inside the Bottle run(...) method.

Here hello_bottle.py :

from bottle import route, run, template
import os

@route('/hello/<name>')
def index(name):
    return template('<b>Hello {{name}}</b>!', name=name)

data_dir='/'

#we give ssl_options to the Tornado server :
run(host='localhost', port=8080,server='tornado',ssl_options={
    "certfile": os.path.join(data_dir, "mydomain.crt"),
    "keyfile": os.path.join(data_dir, "mydomain.key"),
})

And when we execute :

python hello_bottle.py

Bottle v0.13-dev server starting up (using TornadoServer(ssl_options={'keyfile': '/mydomain.key', 'certfile': '/mydomain.crt'}))...
Listening on http://localhost:8080/
Hit Ctrl-C to quit.

Voila :o)


Source : 
SSL with Tornado :

Sending parameters to CherryPy:

Servers allowed with Bottle :

Aucun commentaire:

Categories