from . import db import bottle from urllib.parse import unquote, quote import os import pathlib static_dir = os.path.join(os.path.expanduser('~'), 'lazy_wiki') bottle.TEMPLATE_PATH = [os.path.join(os.path.dirname(__file__), 'views')] app = bottle.Bottle() # Serve CSS @app.get('/static/css/') def serve_css(filename): return bottle.static_file(filename, root=pathlib.Path(__file__).parent / 'static/css') @app.get('/favicon.ico', method='GET') def get_favicon(): return bottle.static_file('favicon.ico', root=pathlib.Path(__file__).parent / 'static/img') # Error Page @app.error(404) def error404(error): return "unfortunately, a 404 error. the page you're searching for doesn't exist. (or is it just in hiding?) try another page! -return to blessfrey- " @app.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-" @app.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-" @app.get('/') def home(): return get_article(Main_Page) @app.get('/Home') def home1(): return get_article(Main_Page) @app.get('/Index') def home2(): return get_article(Main_Page) @app.get('/Main') def home3(): return get_article(Main_Page) @app.get('/Main_Page') def home4(): return get_article(Main_Page) @app.get('/view/') def get_article(keyword): ''' Get an article. ''' article = db.select_formatted_article(unquote(keyword)) return bottle.template('view', article = article)