import datetime, os, re from bottle import error, response, route, run, static_file, template, TEMPLATE_PATH def find_year(): now = datetime.datetime.now() return now.strftime('%Y') ## Static ## # Serve CSS @route('/static/css/') def serve_css(filename): return static_file(filename, root='static/css') # Serve images @route('/static/img/') def serve_img(filename): return static_file(filename, root='static/img') # Serve XML @route('/static/xml/') def serve_xml(filename): return static_file(filename, root='static/xml', mimetype='text/xml') ## Routes ## # Error Page @error(404) def error404(error): return "unfortunately, a 404 error. the page you're searching for doesn't exist. (or am I just hiding it for now?) try another page! " @error(500) def error500(error): return "unfortunately, a 500 error. something is wrong with the page you're trying to find, if it exists at all. try another page! return to blessfrey.me." @error(502) def error502(error): return "unfortunately, a 502 error. this was likely due to website maintenance. usually it'll be back up before you finish reading this, but otherwise, I'll notice something's wrong soon! return to blessfrey.me." # Home Page - Index Template @route('/') def temp(): """temp""" info = {'css': 'index', 'title': 'chimchooree\'s dev space - blessfrey', 'year': find_year()} return template('index.tpl', info) ## Main ## if __name__ == '__main__': run(host='127.0.0.1', port=9001)