{"id":339600,"date":"2022-10-12T15:00:57","date_gmt":"2022-10-12T15:00:57","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=339600"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=339600","title":{"rendered":"<span>\u041c\u0435\u0442\u043e\u0434 Flask flash() \u2014 \u041a\u0430\u043a \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0444\u043b\u044d\u0448-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 Flask?<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/273\/829\/280\/273829280d41463ff120621f58224844.png\" width=\"780\" height=\"439\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/273\/829\/280\/273829280d41463ff120621f58224844.png\"\/><figcaption><\/figcaption><\/figure>\n<p><em>\u0412 \u044d\u0442\u043e\u043c \u0443\u0440\u043e\u043a\u0435 \u043c\u044b \u0443\u0437\u043d\u0430\u0435\u043c \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0444\u043b\u044d\u0448-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 Flask flash()<\/em>.<\/p>\n<h3> \u0427\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0444\u043b\u044d\u0448-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435?<\/h3>\n<p>\u0414\u043b\u044f GUI-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e \u0441\u0432\u044f\u0437\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043d\u0430 \u0435\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f.<\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 <a href=\"https:\/\/www.askpython.com\/python-modules\/flask\/flask-forms\">\u0444\u043e\u0440\u043c\u0435 Flask<\/a>, \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0435 \u043f\u0443\u0441\u0442\u044b\u043c, \u0442\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u0443\u043c\u0435\u0441\u0442\u043d\u043e \u0432\u044b\u0434\u0430\u0442\u044c \u0435\u043c\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435\/\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u043e\u043b\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0434\u043b\u044f \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0412 <a href=\"https:\/\/www.askpython.com\/python\/tkinter-gui-widgets\">\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 Python Tkinter<\/a> \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <a href=\"https:\/\/www.askpython.com\/python-modules\/tkinter\/tkinter-messagebox-and-radiobutton\"><strong>\u043c\u0435\u0441\u0441\u0435\u0434\u0436<\/strong><\/a> \u0438\u043b\u0438 <strong>\u0434\u0438\u0430\u043b\u043e\u0433\u043e\u0432\u043e\u0435 \u043e\u043a\u043d\u043e<\/strong>, \u0430 \u0432 Client-Side Scripting Language JavaScript (\u041a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0438\u0439 \u044f\u0437\u044b\u043a \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432 JavaScript) \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong>alert<\/strong>.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435, \u0432\u043e Flask \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434 flash, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e.<\/p>\n<h3> \u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 Flask flash?<\/h3>\n<p>\u041c\u0435\u0442\u043e\u0434 Flask flash \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c.<\/p>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Flash \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0444\u043b\u044d\u0448-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 Flask, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u0434\u0440\u0443\u0433\u043e\u043c, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u043c &#171;next (\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439)&#187;, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043e\u0431\u044b\u0447\u043d\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u043c (template).<\/p>\n<p>\u0422\u0438\u043f\u0438\u0447\u043d\u044b\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c <a href=\"https:\/\/www.askpython.com\/python-modules\/flask\/flask-templates\">\u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e<\/a> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f:<\/p>\n<pre><code class=\"python\">@app.route('\/template') def blog():     #codes...     #codes...     return render_template('template.html')<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 Flask \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0444\u043b\u044d\u0448-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0438 \u0437\u0430\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0435\u0433\u043e \u0432 <strong>\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 <\/strong>(\u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c), \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e.<\/p>\n<p>\u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0434\u043b\u044f Flash:<\/p>\n<pre><code class=\"python\">flash(message,category)<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c,<\/p>\n<ul>\n<li>\n<p><strong>message :<\/strong> \u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f<\/p>\n<\/li>\n<li>\n<p><strong>category :<\/strong> (\u041a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f). \u041d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u0432 &#171;error&#187; (\u043e\u0448\u0438\u0431\u043a\u0430), &#171;info&#187; (\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f) \u0438\u043b\u0438 &#171;warning&#187; (\u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435).<\/p>\n<\/li>\n<\/ul>\n<p>\u0427\u0442\u043e\u0431\u044b \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0444\u043b\u044d\u0448-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0438\u0437 \u0441\u0435\u0441\u0441\u0438\u0438, \u0433\u0434\u0435 \u043e\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f, \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u0435\u0433\u043e \u043d\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u0435, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <strong>get_flashed_messages()<\/strong>.<\/p>\n<pre><code class=\"python\">get_flashed_messages(with_categories, category_filter)<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c,<\/p>\n<ul>\n<li>\n<p><strong>with_categories :<\/strong> \u041d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0440\u0442\u0435\u0436 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0434\u043b\u044f \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u044f \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 (\u043e\u0448\u0438\u0431\u043a\u0430\/\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f\/\u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435)<\/p>\n<\/li>\n<li>\n<p><strong>category_filter :<\/strong> \u041d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0434\u043b\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 <strong>get_flashed_message()<\/strong> \u0432 \u0444\u0430\u0439\u043b\u0435 Template:<\/p>\n<pre><code class=\"python\">{% with messages = get_flashed_messages() %}    {% if messages %}       {% for message in messages %}          {{ message }}       {% endfor %}    {% endif %} {% endwith %}<\/code><\/pre>\n<h3> \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 flash() \u0432\u043e Flask \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435<\/h3>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 Flask-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c \u0444\u043b\u044d\u0448-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 &#8212; <strong>login successful (\u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0439 \u0432\u0445\u043e\u0434)<\/strong>, \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u0432\u0435\u043b \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u043e\u043b\u044c.<\/p>\n<p><strong>1) \u041a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Flask<\/strong><\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043f\u043e\u043a\u0430\u0436\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0444\u043e\u0440\u043c\u0443, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0430\u0440\u043e\u043b\u044c. \u0415\u0441\u043b\u0438 \u043f\u0430\u0440\u043e\u043b\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439, \u0442\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0444\u043b\u044d\u0448-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435.<\/p>\n<pre><code class=\"python\">from flask import Flask,render_template,request,redirect,flash   app = Flask(__name__)   @app.route('\/form') def form():     return render_template('form.html')   @app.route('\/login', methods = ['POST', 'GET']) def login():     if request.method == 'GET':         return \"Login via the login Form\"           if request.method == 'POST':         password = request.form['password']         if password == '123':             #The following flash message will be displayed on successful login             flash('Login successful')             return render_template('success.html')         else:             return redirect('\/form')<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c <strong>success.html<\/strong> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f &#171;\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c&#187; \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u043c, \u0442\u0430\u043a \u043a\u0430\u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0442\u0430\u043c.<\/p>\n<p>\u0412\u043e\u0442 \u0438 \u0432\u0441\u0435!!! \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u044b.<\/p>\n<p><strong>2) \u041a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432<\/strong><\/p>\n<p>form.html \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0432\u0438\u0434:<\/p>\n<pre><code class=\"python\">&lt;form action=\"\/login\" method = \"POST\">    &lt;p>password &lt;input type = \"text\" name = \"password\" \/>&lt;\/p>    &lt;p>&lt;input type = \"submit\" value = \"Submit\" \/>&lt;\/p> &lt;\/form><\/code><\/pre>\n<p>\u0410 \u0442\u0430\u043a\u0436\u0435 \u0444\u0430\u0439\u043b \u0448\u0430\u0431\u043b\u043e\u043d\u0430 Success.html:<\/p>\n<pre><code class=\"xml\">{% with messages = get_flashed_messages() %}    {% if messages %}       {% for message in messages %}          {{ message }}       {% endfor %}    {% endif %} {% endwith %}   &lt;h2>User Authenticated&lt;\/h2><\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u043a\u0430\u043a \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0437\u0434\u0435\u0441\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <strong>get_flashed_messages()<\/strong>.<\/p>\n<p><strong>3) \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/strong><\/p>\n<p>\u0412\u043e\u0442 \u0438 \u0432\u0441\u0435!!! \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043d\u0430\u0448\u0443 \u0432\u0435\u0431-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443<\/p>\n<p>\u041d\u0430\u0436\u043c\u0438\u0442\u0435 <strong>&#171;\/form&#187;<\/strong>:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/fbb\/8c4\/3fa\/fbb8c43fa4433695b666040d5ba0bab6.png\" width=\"626\" height=\"241\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fbb\/8c4\/3fa\/fbb8c43fa4433695b666040d5ba0bab6.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0424\u043e\u0440\u043c\u0430<\/p>\n<p>\u0412\u0432\u0435\u0434\u0438\u0442\u0435 <strong>1234 <\/strong>\u0438 \u043d\u0430\u0436\u043c\u0438\u0442\u0435 \u043a\u043d\u043e\u043f\u043a\u0443 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0f5\/d42\/a3b\/0f5d42a3be0111837ee8ec5084805208.png\" width=\"626\" height=\"241\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0f5\/d42\/a3b\/0f5d42a3be0111837ee8ec5084805208.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412\u0445\u043e\u0434 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443<\/p>\n<p>\u0418 \u0432\u043e\u0442 \u043e\u043d\u043e, \u043d\u0430\u0448\u0435 \u0444\u043b\u044d\u0448-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043f\u0440\u044f\u043c\u043e \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435.<\/p>\n<h3> \u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0412\u043e\u0442 \u0438 \u0432\u0441\u0435 \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u0443\u0440\u043e\u043a\u0443, \u0440\u0435\u0431\u044f\u0442\u0430! \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0437\u043d\u0430\u043d\u0438\u0439, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 Flash \u0432 \u0441\u0432\u043e\u0438\u0445 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445. \u041e\u0437\u043d\u0430\u043a\u043e\u043c\u044c\u0442\u0435\u0441\u044c \u0441 \u043d\u0430\u0448\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435\u0439 <a href=\"https:\/\/www.askpython.com\/python-modules\/flask\/flask-forms\">Flask Forms<\/a>, \u0447\u0442\u043e\u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043e \u0444\u043e\u0440\u043c\u0430\u0445.<\/p>\n<p>\u0423\u0432\u0438\u0434\u0438\u043c\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435! \u0421\u0447\u0430\u0441\u0442\u043b\u0438\u0432\u043e\u0433\u043e \u043a\u043e\u0434\u0438\u043d\u0433\u0430!!!<\/p>\n<blockquote>\n<p>\u041c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u0430 (classmethod): \u043d\u0443\u0436\u043d\u044b \u043b\u0438 \u043e\u043d\u0438? \u041f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u0435\u043c \u0432\u0441\u0435\u0445 \u043d\u0430 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439 \u0443\u0440\u043e\u043a, \u0433\u0434\u0435 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e\u0431 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u0445 \u041e\u041e\u041f \u0432 python: \u043e \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0438 \u0438 \u043c\u0438\u043a\u0441\u0438\u043d\u0430\u0445.  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 \u0431\u0435\u0437 classmethod \u043d\u0435 \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c.  \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u0445.<\/p>\n<p> &#8212; <a href=\"https:\/\/otus.pw\/cwGz\/\">\u0417\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439 \u0443\u0440\u043e\u043a<\/a><\/p>\n<\/blockquote>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/692820\/\"> https:\/\/habr.com\/ru\/company\/otus\/blog\/692820\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p><em>\u0412 \u044d\u0442\u043e\u043c \u0443\u0440\u043e\u043a\u0435 \u043c\u044b \u0443\u0437\u043d\u0430\u0435\u043c \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0444\u043b\u044d\u0448-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 Flask flash()<\/em>.<\/p>\n<h3> \u0427\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0444\u043b\u044d\u0448-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435?<\/h3>\n<p>\u0414\u043b\u044f GUI-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e \u0441\u0432\u044f\u0437\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043d\u0430 \u0435\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f.<\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 <a href=\"https:\/\/www.askpython.com\/python-modules\/flask\/flask-forms\">\u0444\u043e\u0440\u043c\u0435 Flask<\/a>, \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0435 \u043f\u0443\u0441\u0442\u044b\u043c, \u0442\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u0443\u043c\u0435\u0441\u0442\u043d\u043e \u0432\u044b\u0434\u0430\u0442\u044c \u0435\u043c\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435\/\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u043e\u043b\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0434\u043b\u044f \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0412 <a href=\"https:\/\/www.askpython.com\/python\/tkinter-gui-widgets\">\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 Python Tkinter<\/a> \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <a href=\"https:\/\/www.askpython.com\/python-modules\/tkinter\/tkinter-messagebox-and-radiobutton\"><strong>\u043c\u0435\u0441\u0441\u0435\u0434\u0436<\/strong><\/a> \u0438\u043b\u0438 <strong>\u0434\u0438\u0430\u043b\u043e\u0433\u043e\u0432\u043e\u0435 \u043e\u043a\u043d\u043e<\/strong>, \u0430 \u0432 Client-Side Scripting Language JavaScript (\u041a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0438\u0439 \u044f\u0437\u044b\u043a \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432 JavaScript) \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong>alert<\/strong>.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435, \u0432\u043e Flask \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434 flash, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e.<\/p>\n<h3> \u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 Flask flash?<\/h3>\n<p>\u041c\u0435\u0442\u043e\u0434 Flask flash \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c.<\/p>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Flash \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0444\u043b\u044d\u0448-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 Flask, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u0434\u0440\u0443\u0433\u043e\u043c, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u043c &#171;next (\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439)&#187;, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043e\u0431\u044b\u0447\u043d\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u043c (template).<\/p>\n<p>\u0422\u0438\u043f\u0438\u0447\u043d\u044b\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c <a href=\"https:\/\/www.askpython.com\/python-modules\/flask\/flask-templates\">\u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e<\/a> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f:<\/p>\n<pre><code class=\"python\">@app.route('\/template') def blog():     #codes...     #codes...     return render_template('template.html')<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 Flask \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0444\u043b\u044d\u0448-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0438 \u0437\u0430\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0435\u0433\u043e \u0432 <strong>\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 <\/strong>(\u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c), \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e.<\/p>\n<p>\u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0434\u043b\u044f Flash:<\/p>\n<pre><code class=\"python\">flash(message,category)<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c,<\/p>\n<ul>\n<li>\n<p><strong>message :<\/strong> \u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f<\/p>\n<\/li>\n<li>\n<p><strong>category :<\/strong> (\u041a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f). \u041d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u0432 &#171;error&#187; (\u043e\u0448\u0438\u0431\u043a\u0430), &#171;info&#187; (\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f) \u0438\u043b\u0438 &#171;warning&#187; (\u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435).<\/p>\n<\/li>\n<\/ul>\n<p>\u0427\u0442\u043e\u0431\u044b \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0444\u043b\u044d\u0448-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0438\u0437 \u0441\u0435\u0441\u0441\u0438\u0438, \u0433\u0434\u0435 \u043e\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f, \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u0435\u0433\u043e \u043d\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u0435, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <strong>get_flashed_messages()<\/strong>.<\/p>\n<pre><code class=\"python\">get_flashed_messages(with_categories, category_filter)<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c,<\/p>\n<ul>\n<li>\n<p><strong>with_categories :<\/strong> \u041d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0440\u0442\u0435\u0436 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0434\u043b\u044f \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u044f \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 (\u043e\u0448\u0438\u0431\u043a\u0430\/\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f\/\u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435)<\/p>\n<\/li>\n<li>\n<p><strong>category_filter :<\/strong> \u041d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0434\u043b\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0439 <strong>get_flashed_message()<\/strong> \u0432 \u0444\u0430\u0439\u043b\u0435 Template:<\/p>\n<pre><code class=\"python\">{% with messages = get_flashed_messages() %}    {% if messages %}       {% for message in messages %}          {{ message }}       {% endfor %}    {% endif %} {% endwith %}<\/code><\/pre>\n<h3> \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 flash() \u0432\u043e Flask \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435<\/h3>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 Flask-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c \u0444\u043b\u044d\u0448-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 &#8212; <strong>login successful (\u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0439 \u0432\u0445\u043e\u0434)<\/strong>, \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u0432\u0435\u043b \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u043e\u043b\u044c.<\/p>\n<p><strong>1) \u041a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Flask<\/strong><\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043f\u043e\u043a\u0430\u0436\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0444\u043e\u0440\u043c\u0443, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0430\u0440\u043e\u043b\u044c. \u0415\u0441\u043b\u0438 \u043f\u0430\u0440\u043e\u043b\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439, \u0442\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0444\u043b\u044d\u0448-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435.<\/p>\n<pre><code class=\"python\">from flask import Flask,render_template,request,redirect,flash   app = Flask(__name__)   @app.route('\/form') def form():     return render_template('form.html')   @app.route('\/login', methods = ['POST', 'GET']) def login():     if request.method == 'GET':         return \"Login via the login Form\"           if request.method == 'POST':         password = request.form['password']         if password == '123':             #The following flash message will be displayed on successful login             flash('Login successful')             return render_template('success.html')         else:             return redirect('\/form')<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c <strong>success.html<\/strong> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f &#171;\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c&#187; \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u043c, \u0442\u0430\u043a \u043a\u0430\u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0442\u0430\u043c.<\/p>\n<p>\u0412\u043e\u0442 \u0438 \u0432\u0441\u0435!!! \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u0443\u0435\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u044b.<\/p>\n<p><strong>2) \u041a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432<\/strong><\/p>\n<p>form.html \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0432\u0438\u0434:<\/p>\n<pre><code class=\"python\">&lt;form action=\"\/login\" method = \"POST\">    &lt;p>password &lt;input type = \"text\" name = \"password\" \/>&lt;\/p>    &lt;p>&lt;input type = \"submit\" value = \"Submit\" \/>&lt;\/p> &lt;\/form><\/code><\/pre>\n<p>\u0410 \u0442\u0430\u043a\u0436\u0435 \u0444\u0430\u0439\u043b \u0448\u0430\u0431\u043b\u043e\u043d\u0430 Success.html:<\/p>\n<pre><code class=\"xml\">{% with messages = get_flashed_messages() %}    {% if messages %}       {% for message in messages %}          {{ message }}       {% endfor %}    {% endif %} {% endwith %}   &lt;h2>User Authenticated&lt;\/h2><\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u043a\u0430\u043a \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0437\u0434\u0435\u0441\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <strong>get_flashed_messages()<\/strong>.<\/p>\n<p><strong>3) \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/strong><\/p>\n<p>\u0412\u043e\u0442 \u0438 \u0432\u0441\u0435!!! \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043d\u0430\u0448\u0443 \u0432\u0435\u0431-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443<\/p>\n<p>\u041d\u0430\u0436\u043c\u0438\u0442\u0435 <strong>&#171;\/form&#187;<\/strong>:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0424\u043e\u0440\u043c\u0430<\/p>\n<p>\u0412\u0432\u0435\u0434\u0438\u0442\u0435 <strong>1234 <\/strong>\u0438 \u043d\u0430\u0436\u043c\u0438\u0442\u0435 \u043a\u043d\u043e\u043f\u043a\u0443 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412\u0445\u043e\u0434 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443<\/p>\n<p>\u0418 \u0432\u043e\u0442 \u043e\u043d\u043e, \u043d\u0430\u0448\u0435 \u0444\u043b\u044d\u0448-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043f\u0440\u044f\u043c\u043e \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435.<\/p>\n<h3> \u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0412\u043e\u0442 \u0438 \u0432\u0441\u0435 \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u0443\u0440\u043e\u043a\u0443, \u0440\u0435\u0431\u044f\u0442\u0430! \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0437\u043d\u0430\u043d\u0438\u0439, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 Flash \u0432 \u0441\u0432\u043e\u0438\u0445 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445. \u041e\u0437\u043d\u0430\u043a\u043e\u043c\u044c\u0442\u0435\u0441\u044c \u0441 \u043d\u0430\u0448\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435\u0439 <a href=\"https:\/\/www.askpython.com\/python-modules\/flask\/flask-forms\">Flask Forms<\/a>, \u0447\u0442\u043e\u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043e \u0444\u043e\u0440\u043c\u0430\u0445.<\/p>\n<p>\u0423\u0432\u0438\u0434\u0438\u043c\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435! \u0421\u0447\u0430\u0441\u0442\u043b\u0438\u0432\u043e\u0433\u043e \u043a\u043e\u0434\u0438\u043d\u0433\u0430!!!<\/p>\n<blockquote>\n<p>\u041c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u0430 (classmethod): \u043d\u0443\u0436\u043d\u044b \u043b\u0438 \u043e\u043d\u0438? \u041f\u0440\u0438\u0433\u043b\u0430\u0448\u0430\u0435\u043c \u0432\u0441\u0435\u0445 \u043d\u0430 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439 \u0443\u0440\u043e\u043a, \u0433\u0434\u0435 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e\u0431 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u0445 \u041e\u041e\u041f \u0432 python: \u043e \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0438 \u0438 \u043c\u0438\u043a\u0441\u0438\u043d\u0430\u0445.  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 \u0431\u0435\u0437 classmethod \u043d\u0435 \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c.  \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u0445.<\/p>\n<p> &#8212; <a href=\"https:\/\/otus.pw\/cwGz\/\">\u0417\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439 \u0443\u0440\u043e\u043a<\/a><\/p>\n<\/blockquote>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/692820\/\"> https:\/\/habr.com\/ru\/company\/otus\/blog\/692820\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-339600","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/339600","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=339600"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/339600\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=339600"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=339600"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=339600"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}