Created
March 22, 2014 19:25
-
-
Save mramu111/9712857 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bottle import Bottle, template | |
class Server: | |
def __init__(self, host, port): | |
self._host = host | |
self._port = port | |
self._app = Bottle() | |
self._route() | |
def _route(self): | |
self._app.route('/', method="GET", callback=self._index) | |
self._app.route('/hello/<name>', callback=self._hello) | |
def start(self): | |
self._app.run(host=self._host, port=self._port) | |
def _index(self): | |
return 'Welcome' | |
def _hello(self, name="Guest"): | |
return template('Hello {{name}}, how are you?', name=name) | |
server = Server(host='localhost', port=8090) | |
server.start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment