63 lines
1.7 KiB
Python
63 lines
1.7 KiB
Python
__author__ = 'RemiZOffAlex'
|
||
__copyright__ = '(c) RemiZOffAlex'
|
||
__license__ = 'MIT'
|
||
__email__ = 'remizoffalex@mail.ru'
|
||
__url__ = 'https://remizoffalex.ru'
|
||
|
||
from myapp import app
|
||
from flask import Flask, render_template, request, Response
|
||
|
||
from . import forms, models
|
||
|
||
|
||
@app.route('/')
|
||
def index():
|
||
pagedata = {}
|
||
pagedata['title'] = app.config['TITLE']
|
||
pagedata['info'] = 'Привет мир!'
|
||
body = render_template('index.html', pagedata=pagedata)
|
||
return body
|
||
|
||
|
||
@app.route('/page')
|
||
def page():
|
||
pagedata = {}
|
||
pagedata['title'] = app.config['TITLE']
|
||
pagedata['page'] = {
|
||
'title': 'Заголовок страницы',
|
||
'text': '''<p>Текст</p>
|
||
<p class="alert alert-danger">Внимание!</p>'''
|
||
}
|
||
body = render_template('page.html', pagedata=pagedata)
|
||
return body
|
||
|
||
|
||
@app.route("/robots.txt")
|
||
def robots_txt():
|
||
body = render_template("robots.txt")
|
||
return Response(body, mimetype='text/plain')
|
||
|
||
|
||
# noinspection PyUnusedLocal
|
||
@app.errorhandler(404)
|
||
def error_missing(exception):
|
||
pagedata = {}
|
||
error_message = "Не судьба..."
|
||
return render_template("error.html", error_code=404, error_message=error_message, pagedata=pagedata), 404
|
||
|
||
|
||
# noinspection PyUnusedLocal
|
||
@app.errorhandler(403)
|
||
def error_unauthorized(exception):
|
||
pagedata = {}
|
||
error_message = "У вас нет прав"
|
||
return render_template("error.html", error_code=403, error_message=error_message, pagedata=pagedata), 403
|
||
|
||
|
||
# noinspection PyUnusedLocal
|
||
@app.errorhandler(500)
|
||
def error_crash(exception):
|
||
pagedata = {}
|
||
error_message = "Вот незадача..."
|
||
return render_template("error.html", error_code=500, error_message=error_message, pagedata=pagedata), 500
|