#main.py import os from bottle import run, route, template from controllers import home @route('/') def main(): return home.index() if 'DYNO' in os.environ: run(host='0.0.0.0', port=os.environ.get('PORT', 9000)) else: run(host='localhost', port=9000, debug=True, reloader=True)
#controllers/home.py import config from bottle import route, template config.kargs['message'] = "Hello World!" def index(): return template('home', data=config.kargs)
<!--views/home.tpl--> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"/> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <title>{{data['blogTitle']}}</title> </head> <body> {{data['message']}} </body> </html>
GitHub: https://github.com/Sokhavuth/kwblog
Heroku: https://khmerweb-kwblog.herokuapp.com/