pymove3d.py
author Peter Koppatz <peter@koppatz.com>
Sat, 18 Jan 2014 11:36:43 +0100
changeset 109 bd4b675d9214
parent 100 fbc07ac77baa
child 112 61b346446ea7
permissions -rwxr-xr-x
negotiation set to standard value if none
     1 from flask import Flask
     2 from flask import render_template
     3 from flask import request
     4 from flask import abort, redirect, url_for
     5 import os
     6 from flask import send_from_directory
     7 import logging
     8 from logging import Formatter
     9 
    10 from flask.ext.babel import gettext as _
    11 from flask.ext.babel import Babel
    12 
    13 from config import LANGUAGES
    14 
    15 
    16 app = Flask(__name__)
    17 babel = Babel(app)
    18 
    19 @babel.localeselector
    20 def get_locale():
    21     """ToDo: if translation is completed, switch to en """
    22     return request.accept_languages.best_match(LANGUAGES.keys()) or 'de'
    23 
    24 
    25 @app.route("/")
    26 
    27 @app.route("/index")
    28 def index():
    29     return render_template(get_locale() + "/index.html")
    30 
    31 @app.route("/competition")
    32 def competition():
    33     return render_template(get_locale() + "/competition.html", act="competition")
    34 
    35 @app.route("/task")
    36 def task():
    37     return render_template(get_locale() + "/task.html", act="task")
    38 
    39 @app.route("/submission")
    40 def submission():
    41     return render_template(get_locale() + "/submission.html", act="submission")
    42 
    43 @app.route("/coursematerial")
    44 def coursematerial():
    45     return render_template(get_locale() + "/coursematerial.html", act="coursematerial")
    46 
    47 @app.route("/imprint")
    48 def imprint():
    49     return render_template(get_locale() + "/imprint.html", act="imprint")
    50 
    51 @app.route("/privacy")
    52 def privacy():
    53     return render_template(get_locale() + "/privacy.html", act="privacy")
    54 
    55 @app.route(_("/competition-2013"))
    56 def competition_2013():
    57     return render_template(get_locale() + "/archive/competitions/2013/comptetition_2013.html", 
    58                            act="coursematerial")
    59 
    60 @app.route(_("/competition-2014"))
    61 def competition_2014():
    62     return render_template(get_locale() + "archive/competitions/2014/competition_2014.html", 
    63                            act="coursematerial")
    64 
    65 @app.errorhandler(404)
    66 def page_not_found(e):
    67     return render_template(get_locale() + "/404.html")
    68 
    69 if __name__ == "__main__":
    70     app.run(host='localhost', port=5014, debug=True)
    71 
    72 
Impressum Datenschutzerklärung