2018-02-26 09:59:54 +03:00
|
|
|
|
__author__ = 'RemiZOffAlex'
|
|
|
|
|
|
__copyright__ = '(c) RemiZOffAlex'
|
|
|
|
|
|
__license__ = 'MIT'
|
|
|
|
|
|
__email__ = 'remizoffalex@mail.ru'
|
2019-04-26 15:38:41 +03:00
|
|
|
|
__url__ = 'https://remizoffalex.ru'
|
2018-02-26 09:59:54 +03:00
|
|
|
|
|
|
|
|
|
|
from myapp import app
|
2019-10-27 19:40:03 +03:00
|
|
|
|
from flask import Flask, render_template, request, Response
|
2018-02-26 09:59:54 +03:00
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-10-27 19:40:03 +03:00
|
|
|
|
@app.route('/page')
|
|
|
|
|
|
def page():
|
2018-02-26 09:59:54 +03:00
|
|
|
|
pagedata = {}
|
|
|
|
|
|
pagedata['title'] = app.config['TITLE']
|
2019-10-27 19:40:03 +03:00
|
|
|
|
pagedata['page'] = {
|
|
|
|
|
|
'title': 'Заголовок страницы',
|
|
|
|
|
|
'text': '''<p>Текст</p>
|
2018-02-26 09:59:54 +03:00
|
|
|
|
<p class="alert alert-danger">Внимание!</p>'''
|
2019-10-27 19:40:03 +03:00
|
|
|
|
}
|
|
|
|
|
|
body = render_template('page.html', pagedata=pagedata)
|
2018-02-26 09:59:54 +03:00
|
|
|
|
return body
|
2019-10-27 19:40:03 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@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
|