Перенесено из репозитария SpecialistOff.NET

This commit is contained in:
2018-02-26 09:59:54 +03:00
parent b7d2da4899
commit 5a727393c9
358 changed files with 46103 additions and 0 deletions

51
myapp/views.py Normal file
View File

@@ -0,0 +1,51 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
__author__ = 'RemiZOffAlex'
__copyright__ = '(c) RemiZOffAlex'
__license__ = 'MIT'
__email__ = 'remizoffalex@mail.ru'
from myapp import app
from flask import Flask, render_template, request
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('/edit', methods=['GET', 'POST'])
def edit():
pagedata = {}
pagedata['title'] = app.config['TITLE']
pagedata['form'] = forms.PageEdit(
request.form,
data={
'title': 'Заголовок страницы',
'text': '''<p>Текст</p>
<p class="alert alert-danger">Внимание!</p>'''
}
)
if request.method == 'POST':
if pagedata['form'].validate():
pagedata['title'] = pagedata['form'].title.data
pagedata['text'] = pagedata['form'].text.data
body = render_template('page.html', pagedata=pagedata)
return body
body = render_template('edit.html', pagedata=pagedata)
return body
@app.route('/login', methods=['GET', 'POST'])
def login():
pagedata = {}
pagedata['form'] = forms.LoginForm(request.form)
body = render_template('login.html', pagedata=pagedata)
return body