pymove3d.py
author stetrabby <info@trabucchi.de>
Sat, 18 Jan 2014 12:34:36 +0100
changeset 114 6093dda9fe38
parent 112 61b346446ea7
child 118 8f3447e7f36e
permissions -rwxr-xr-x
front-page main content changed
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():
peter@109
    21
    """ToDo: if translation is completed, switch to en """
peter@109
    22
    return request.accept_languages.best_match(LANGUAGES.keys()) or 'de'
peter@1
    23
rb@100
    24
peter@1
    25
@app.route("/")
peter@1
    26
rb@100
    27
@app.route("/index")
peter@1
    28
def index():
rb@100
    29
    return render_template(get_locale() + "/index.html")
peter@1
    30
rb@100
    31
@app.route("/competition")
peter@1
    32
def competition():
rb@100
    33
    return render_template(get_locale() + "/competition.html", act="competition")
peter@1
    34
rb@100
    35
@app.route("/task")
peter@1
    36
def task():
rb@100
    37
    return render_template(get_locale() + "/task.html", act="task")
peter@1
    38
rb@100
    39
@app.route("/submission")
peter@1
    40
def submission():
rb@100
    41
    return render_template(get_locale() + "/submission.html", act="submission")
peter@1
    42
rb@100
    43
@app.route("/coursematerial")
peter@1
    44
def coursematerial():
rb@100
    45
    return render_template(get_locale() + "/coursematerial.html", act="coursematerial")
peter@1
    46
rb@100
    47
@app.route("/imprint")
peter@88
    48
def imprint():
peter@109
    49
    return render_template(get_locale() + "/imprint.html", act="imprint")
peter@88
    50
rb@100
    51
@app.route("/privacy")
peter@88
    52
def privacy():
rb@100
    53
    return render_template(get_locale() + "/privacy.html", act="privacy")
peter@88
    54
hr@112
    55
peter@109
    56
@app.route(_("/competition-2013"))
peter@109
    57
def competition_2013():
hr@112
    58
    return render_template(get_locale() + "/archive/competitions/2013/comptetition_2013.html",
peter@109
    59
                           act="coursematerial")
peter@109
    60
peter@109
    61
@app.route(_("/competition-2014"))
peter@109
    62
def competition_2014():
hr@112
    63
    return render_template(get_locale() + "archive/competitions/2014/competition_2014.html",
peter@109
    64
                           act="coursematerial")
peter@88
    65
hr@112
    66
@app.route(_("/dates"))
hr@112
    67
def dates():
hr@112
    68
    return render_template(get_locale() + "/dates.html",
hr@112
    69
                           act="dates")
hr@112
    70
hr@112
    71
peter@1
    72
@app.errorhandler(404)
peter@1
    73
def page_not_found(e):
rb@100
    74
    return render_template(get_locale() + "/404.html")
peter@1
    75
peter@1
    76
if __name__ == "__main__":
peter@1
    77
    app.run(host='localhost', port=5014, debug=True)
peter@1
    78
peter@1
    79
Impressum Datenschutzerklärung