#public/setup.py from bottle import route, static_file @route('/static/scripts/<filename>') def server_static(filename): return static_file(filename, root='./public/js') @route('/static/styles/<filename>') def server_static(filename): return static_file(filename, root='./public/css') @route('/static/images/<filename>') def server_static(filename): return static_file(filename, root='./public/images') @route('/static/fonts/<filename>') def server_static(filename): return static_file(filename, root='./public/fonts')
<!--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> <script src="/static/scripts/jQuery.js"></script> <script src="/static/scripts/main.js"></script> <link href="/static/styles/main.css" rel="stylesheet"></link> <link href="/static/images/site_logo.png" rel="icon" ></link> <link href="/static/fonts/setup.css" rel="stylesheet"></link> </head> <body> {{data['message']}} </body> </html>
#main.py import os from bottle import run, route, template from controllers import home from public import setup @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)
GitHub: https://github.com/Sokhavuth/kwblog
Heroku: https://khmerweb-kwblog.herokuapp.com/