pymove3d.py
author Reimar Bauer <rb.proj AT googlemail DOT com>
Sat, 18 Jan 2014 10:36:12 +0100
changeset 100 fbc07ac77baa
parent 97 9fa249552dba
child 109 bd4b675d9214
permissions -rwxr-xr-x
simplified translation language selector
peter@1
     1
from flask import Flask
peter@1
     2
from flask import render_template
peter@1
     3
from flask import request
peter@1
     4
from flask import abort, redirect, url_for
peter@1
     5
import os
peter@1
     6
from flask import send_from_directory
peter@1
     7
import logging
peter@1
     8
from logging import Formatter
peter@1
     9
rb@95
    10
from flask.ext.babel import gettext as _
peter@1
    11
from flask.ext.babel import Babel
peter@1
    12
rb@95
    13
from config import LANGUAGES
rb@95
    14
rb@95
    15
peter@1
    16
app = Flask(__name__)
peter@1
    17
babel = Babel(app)
peter@1
    18
peter@1
    19
@babel.localeselector
peter@1
    20
def get_locale():
rb@95
    21
    return request.accept_languages.best_match(LANGUAGES.keys())
peter@1
    22
rb@100
    23
peter@1
    24
@app.route("/")
peter@1
    25
rb@100
    26
@app.route("/index")
peter@1
    27
def index():
rb@100
    28
    return render_template(get_locale() + "/index.html")
peter@1
    29
rb@100
    30
@app.route("/competition")
peter@1
    31
def competition():
rb@100
    32
    return render_template(get_locale() + "/competition.html", act="competition")
peter@1
    33
rb@100
    34
@app.route("/task")
peter@1
    35
def task():
rb@100
    36
    return render_template(get_locale() + "/task.html", act="task")
peter@1
    37
rb@100
    38
@app.route("/submission")
peter@1
    39
def submission():
rb@100
    40
    return render_template(get_locale() + "/submission.html", act="submission")
peter@1
    41
rb@100
    42
@app.route("/coursematerial")
peter@1
    43
def coursematerial():
rb@100
    44
    return render_template(get_locale() + "/coursematerial.html", act="coursematerial")
peter@1
    45
rb@100
    46
@app.route("/imprint")
peter@88
    47
def imprint():
rb@100
    48
    return render_template(get_locale () + "/imprint.html", act="imprint")
peter@88
    49
rb@100
    50
@app.route("/privacy")
peter@88
    51
def privacy():
rb@100
    52
    return render_template(get_locale() + "/privacy.html", act="privacy")
peter@88
    53
peter@88
    54
peter@1
    55
@app.errorhandler(404)
peter@1
    56
def page_not_found(e):
rb@100
    57
    return render_template(get_locale() + "/404.html")
peter@1
    58
peter@1
    59
if __name__ == "__main__":
peter@1
    60
    app.run(host='localhost', port=5014, debug=True)
peter@1
    61
peter@1
    62
Impressum Datenschutzerklärung