peter@1: from flask import Flask peter@1: from flask import render_template peter@1: from flask import request peter@1: from flask import abort, redirect, url_for peter@1: import os peter@1: from flask import send_from_directory peter@1: import logging peter@1: from logging import Formatter peter@1: rb@95: from flask.ext.babel import gettext as _ peter@1: from flask.ext.babel import Babel peter@1: rb@95: from config import LANGUAGES rb@95: rb@95: peter@1: app = Flask(__name__) peter@1: babel = Babel(app) peter@1: peter@1: @babel.localeselector peter@1: def get_locale(): rb@95: return request.accept_languages.best_match(LANGUAGES.keys()) peter@1: peter@1: @app.route("/") peter@1: rb@95: @app.route(_("/index")) peter@1: def index(): rb@95: return render_template(_("en/index.html")) peter@1: rb@95: @app.route(_("/competition")) peter@1: def competition(): rb@95: return render_template(_("en/competition.html"), act="competition") peter@1: rb@95: @app.route(_("/task")) peter@1: def task(): rb@95: return render_template(_("en/task.html"), act="task") peter@1: rb@95: @app.route(_("/submission")) peter@1: def submission(): rb@95: return render_template(_("en/submission.html"), act="submission") peter@1: rb@95: @app.route(_("/coursematerial")) peter@1: def coursematerial(): rb@95: return render_template(_("en/coursematerial.html"), act="coursematerial") peter@1: rb@95: @app.route(_("/imprint")) peter@88: def imprint(): rb@95: return render_template(_("en/imprint.html"), act="imprint") peter@88: rb@95: @app.route(_("/privacy")) peter@88: def privacy(): rb@95: return render_template(_("en/privacy.html"), act="privacy") peter@88: peter@88: peter@1: @app.errorhandler(404) peter@1: def page_not_found(e): rb@97: return render_template(_("en/404.html")), 404 peter@1: peter@1: if __name__ == "__main__": peter@1: app.run(host='localhost', port=5014, debug=True) peter@1: peter@1: