blob: 34a6cd3d8b1cd30502ecfdce051519df854a788a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#!/usr/bin/python3
import sys
import time
from flask import Flask, abort, render_template, redirect, url_for, request
from werkzeug.exceptions import default_exceptions
import jinja2.exceptions
app = Flask(__name__)
app.jinja_env.auto_reload = True
app.config['TEMPLATES_AUTO_RELOAD'] = True
@app.context_processor
def injetar_dados_basicos():
return dict(organizacao = 'FederANA')
def generic_handler(e):
return render_template('/erro.html', erro = e), getattr(e, 'code', 500)
for codigo in default_exceptions:
app.errorhandler(codigo)(generic_handler)
@app.route('/')
def index():
return redirect('/index.html')
@app.route('/<path:caminho>.html')
def ver_pagina(caminho):
try:
return render_template('/' + caminho + '.html')
except jinja2.exceptions.TemplateNotFound as e:
abort(404)
|