1
0
Fork 0
mirror of https://github.com/EDeev/yandex_lyceum.git synced 2026-10-07 20:49:29 +03:00
yandex_lyceum/02-flask-wtf-forms/server.py
Egor Deev 968588eea1 Ключ API Яндекс.Карт и SECRET_KEY из окружения, зависимости только используемые
requirements.txt сокращён до Flask, Flask-WTF, WTForms, requests и Pillow; Werkzeug
закреплён на 2.3 — с Werkzeug 3 Flask-WTF 1.1 не импортируется.
2026-10-02 21:18:33 +00:00

55 lines
1.8 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import os
from flask import Flask, render_template, redirect
from loginform import LoginForm
app = Flask(__name__)
app.config['SECRET_KEY'] = os.environ.get('SECRET_KEY', 'yandexlyceum_secret_key')
@app.route('/<label>')
@app.route('/index/<label>')
def index(label):
param = {'label': 'И на Марсе будут яблони цвести!', 'title': label}
return render_template('index.html', **param)
@app.route('/training/<prof>')
def training(prof):
param = {'title': "Тренировки в полёте", "spec": prof}
return render_template('training.html', **param)
@app.route('/list_prof/<var>')
def list_prof(var):
param = {'title': "Список профессий", "var": var}
return render_template('list_prof.html', **param)
@app.route('/answer')
@app.route('/auto_answer')
def answer():
param = {'title': "Анкета", 'surname': "Фёдоров", 'name': "Марк", 'education': "Среднее", 'profession': " Писатель",
'sex': "Male", 'motivation': "Распространить хип-хоп в космос!", 'ready': "True"}
return render_template('auto_answer.html', **param)
@app.route('/login', methods=['GET', 'POST'])
def login():
param = {'title': "Аварийный доступ"}
form = LoginForm()
if form.validate_on_submit():
return redirect('/success')
return render_template('login.html', **param, form=form)
@app.route('/distribution')
def success():
param = {'title': "По каютам!", "users": ['Ридли Скотт', 'Энди Уир', 'Марк Уотни', "Венката Капур",
'Тедди Сандерс', 'Шон Бин']}
return render_template('distribution.html', **param)
if __name__ == '__main__':
app.run(port=8080, host='127.0.0.1')