# http://bottlepy.org/docs/dev/tutorial.html
from __future__ import print_function
import os.path
import bottle
from random import randrange
bottle.debug(True) #sollte spaeter ausgeschaltet werden!
bottle.TEMPLATE_PATH.insert(0, os.path.join(os.path.dirname(__file__), 'templates'))
@bottle.route('/')
def MainHandler():
values = {
'test': randrange(1, 1000),
}
return bottle.template('index.html', values)
@bottle.route('/static/<filename>')
def StaticHandler(filename):
if filename.endswith(".css"):
bottle.response.content_type = 'text/css'
elif filename.endswith(".js"):
bottle.response.content_type = 'text/javascript'
elif filename.endswith(".png"):
bottle.response.content_type = 'image/png'
return bottle.static_file(filename, root=os.path.join(os.path.dirname(__file__), 'static'))
@bottle.error(404)
def error404(error):
return 'Error 404: Nothing here, sorry.'
try:
bottle.run(host='0.0.0.0', port=8080, quiet=True)
except (KeyboardInterrupt, SystemExit):
print('\nQuit\n')