{"id":272124,"date":"2016-01-14T13:55:08","date_gmt":"2016-01-14T10:55:08","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=272124"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=272124","title":{"rendered":"\u041f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0432 Flask"},"content":{"rendered":"<p>       <i>\u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f, <a href=\"https:\/\/github.com\/mitsuhiko\/flask\/wiki\/Large-app-how-to\">\u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u043d\u0430\u044f<\/a> \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 Flask \u043d\u0430 GitHub, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043b\u043e\u0434\u043e\u043c \u043a\u043e\u043b\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0442\u0432\u043e\u0440\u0447\u0435\u0441\u0442\u0432\u0430 \u043d\u0435\u0431\u0435\u0437\u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432, \u0430 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u0435\u0451 \u0430\u0432\u0442\u043e\u0440 \u2014 <a href=\"http:\/\/bbrriiccee@gmail.com\">Brice Leroy<\/a>. \u041e\u043d\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439 \u0434\u043b\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0445 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u043f\u043e Flask. \u041b\u0438\u0447\u043d\u043e \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u043e\u043d \u0441\u0442\u0430\u043b \u043e\u0442\u0432\u0435\u0442\u043e\u043c \u043d\u0430 \u043c\u043d\u043e\u0433\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u044b\u043b \u00ab\u043a\u0430\u043a \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442\u00bb.<\/p>\n<p>  \u0414\u043b\u044f \u0445\u043e\u0442\u044c \u0441\u043a\u043e\u043b\u044c\u043a\u043e-\u0442\u043e \u043e\u043f\u044b\u0442\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432 \u043e\u043d\u0430 \u0432\u0440\u044f\u0434 \u043b\u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u0430, \u043c\u043d\u043e\u0433\u0438\u0435 \u043c\u043e\u0433\u0443\u0442 \u0432\u043e\u0432\u0441\u0435 \u043d\u0435 \u0441\u043e\u0433\u043b\u0430\u0441\u0438\u0442\u044c\u0441\u044f \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430\u043c\u0438, \u043e\u0434\u043d\u0430\u043a\u043e \u0434\u043b\u044f \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0445\u0441\u044f \u043d\u0430 \u0440\u0430\u043d\u043d\u0435\u0439 \u0441\u0442\u0430\u0434\u0438\u0438 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0442\u044c \u0442\u043e\u043b\u0447\u043a\u043e\u043c \u043a \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044e, \u043a\u0430\u043a \u0441\u0442\u0430\u043b\u0430 \u0434\u043b\u044f \u043c\u0435\u043d\u044f. \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0441\u0434\u0435\u043b\u0430\u043b \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u0438\u0439 \u044f\u0437\u044b\u043a \u2014 \u0443 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043e\u0447\u0435\u043d\u044c \u043d\u0438\u0437\u043a\u0438\u0439 \u043f\u043e\u0440\u043e\u0433 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0438 \u0441\u0442\u043e\u0438\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u0435\u0449\u0435 \u043d\u0438\u0436\u0435.<\/p>\n<p>  \u041e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u043d\u0430 Python 3.5, Flask 0.10, Flask-SQLAlchemy 2.1, Flask-WTG 0.9.<\/i><br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h1>\u041f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0432 Flask<\/h1>\n<p>  \u042d\u0442\u043e\u0442 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u043d\u0435 \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e Flask. \u041e\u043d \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0435\u0439 \u0441\u043e\u0432\u0435\u0442\u043e\u0432, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0438\u0437 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043d\u0435\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u0438 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043f\u043e\u0434\u0432\u0435\u0440\u0433\u0430\u043b\u0441\u044f \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435. \u041e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u0438\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0432\u0435\u0441\u044c\u043c\u0430 \u043f\u043e\u043b\u0435\u0437\u043d\u044b, \u043d\u043e \u0432 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043e\u043f\u0430\u0441\u043d\u044b. \u041f\u0440\u043e\u0441\u044c\u0431\u0430 \u043d\u0435 \u0432\u043d\u043e\u0441\u0438\u0442\u044c \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442, \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u043d\u044b\u0439 \u043d\u0430 Github, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430 \u043d\u0435\u0433\u043e \u0441\u0441\u044b\u043b\u0430\u044e\u0442\u0441\u044f \u043c\u043d\u043e\u0433\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u044b \u043d\u0430 StackOverflow. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u043d\u043e\u0441\u0438\u0442\u044c \u0432 \u043d\u0435\u0433\u043e \u043b\u044e\u0431\u044b\u0435 \u043f\u043e\u043f\u0440\u0430\u0432\u043a\u0438 \u0438 \u0437\u0430\u043c\u0435\u0442\u043a\u0438, \u043d\u043e \u0434\u043b\u044f \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043b\u0438\u0447\u043d\u044b\u0439 \u0441\u0430\u0439\u0442 \u0438\u043b\u0438 \u0431\u043b\u043e\u0433.<\/p>\n<p>  \u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u043f\u044b\u0442\u043a\u043e\u0439 \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0435\u0433\u043e <b>Flask<\/b> \u0438 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438 <b>SQLAlchemy<\/b> \u0438 <b>WTForms<\/b>.<\/p>\n<h2>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430<\/h2>\n<p>  <\/p>\n<h3>Flask<\/h3>\n<p>  <a href=\"http:\/\/flask.pocoo.org\/docs\/0.10\/installation\/\">\u0418\u043d\u0443\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f<\/a> \u043f\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 Flask.<\/p>\n<p>  \u042f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <b>virtualenv<\/b> \u2014 \u044d\u0442\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u0430 \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0439 \u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0438 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u0440\u0430\u0432 \u0441\u0443\u043f\u0435\u0440\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0442\u0430\u043a \u043a\u0430\u043a \u0432\u0441\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e.<\/p>\n<h3>Flask-SQLAlchemy<\/h3>\n<p>  SQLAlchemy \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438 \u043c\u043e\u0449\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0432\u0430\u0448\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438 \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043b\u044e\u0431\u043e\u0433\u043e \u0442\u0438\u043f\u0430. \u0414\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 Flask-SQLAlchemy \u0432 \u0432\u0430\u0448\u0435 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 pip:<\/p>\n<pre><code>pip install flask-sqlalchemy <\/code><\/pre>\n<p>  <a href=\"http:\/\/packages.python.org\/Flask-SQLAlchemy\/\">\u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u043b\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435<\/a> \u043f\u0430\u043a\u0435\u0442\u0430 Flask-SQLAlchemy.<\/p>\n<h3>Flask-WTF<\/h3>\n<p>  <b>WTForms<\/b> \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<pre><code>pip install Flask-WTF <\/code><\/pre>\n<p>  <a href=\"https:\/\/pythonhosted.org\/Flask-WTF\/\">\u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u043b\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435<\/a> \u043f\u0430\u043a\u0435\u0442\u0430 Flask-WTF.<\/p>\n<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>  \u0418\u0442\u0430\u043a, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u044b. \u0422\u0430\u043a \u0434\u043e\u043b\u0436\u043d\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430:<\/p>\n<pre><code>\/app\/users\/__init__.py \/app\/users\/views.py \/app\/users\/forms.py \/app\/users\/constants.py \/app\/users\/models.py \/app\/users\/decorators.py <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u0435\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f (\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f) \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430:<\/p>\n<pre><code>\/app\/templates\/404.html \/app\/templates\/base.html \/app\/templates\/users\/login.html \/app\/templates\/users\/register.html ... <\/code><\/pre>\n<p>  \u0428\u0430\u0431\u043b\u043e\u043d\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f (jinja) \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <em>templates<\/em> \u0438 \u043f\u043e\u0434\u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f \u043c\u043e\u0434\u0443\u043b\u0435\u0439:<\/p>\n<pre><code>\/app\/static\/js\/main.js \/app\/static\/css\/reset.css \/app\/static\/img\/header.png <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440, \u043e\u0434\u043d\u0430\u043a\u043e \u043d\u0430 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0437\u043b\u043e\u0436\u0438\u0442\u044c \u044d\u0442\u0443 \u0440\u0430\u0431\u043e\u0442\u0443 \u043d\u0430 Flask. \u041e\u043d \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u044b\u0434\u0430\u0435\u0442 \u0442\u0430\u043a\u0438\u0435 \u0444\u0430\u0439\u043b\u044b \u0438\u0437 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <em>static<\/em>, \u0430 \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0440\u0443\u0433\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u0438\u0437 <a href=\"http:\/\/flask.pocoo.org\/docs\/0.10\/api\/#application-object\">\u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438<\/a>.<\/p>\n<p>  \u0414\u043b\u044f \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u043d \u043e\u0434\u0438\u043d \u043c\u043e\u0434\u0443\u043b\u044c: users. \u041e\u043d \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0435\u0439 \u0438 \u0432\u0445\u043e\u0434\u043e\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u0432\u043e\u0435\u0433\u043e \u043f\u0440\u043e\u0444\u0430\u0439\u043b\u0430.<\/p>\n<h2>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f<\/h2>\n<p>  <em>\/run.py<\/em> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u0430:<\/p>\n<pre><code>    from app import app     app.run(debug=True) <\/code><\/pre>\n<p>  <em>\/shell.py<\/em> \u0434\u0430\u0441\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043d\u0435 \u0442\u0430\u043a \u0443\u0434\u043e\u0431\u043d\u043e, \u043a\u0430\u043a \u043e\u0442\u043b\u0430\u0434\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 <b>pdb<\/b>, \u043d\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e (\u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435 \u043f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445):<\/p>\n<pre><code>    #!\/usr\/bin\/env python     import os     import readline     from pprint import pprint      from flask import *     from app import *      os.environ['PYTHONINSPECT'] = 'True' <\/code><\/pre>\n<p>  <em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0447\u0438\u043a\u0430:<br \/>  \u0412 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0432\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u0435 \u0432 \u041e\u0421 Windows (\u043d\u0435 \u043d\u0430\u0434\u043e \u0431\u0440\u043e\u0441\u0430\u0442\u044c \u043a\u0438\u0440\u043f\u0438\u0447\u0438!), \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 readline \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0432 \u0441\u0432\u043e\u0451 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u0438\u043b\u0438 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 python \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 pyreadline \u0438 \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u044c \u0438\u043c\u043f\u043e\u0440\u0442 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e \u0432\u0438\u0434\u0430:<\/em><\/p>\n<pre><code>try:     import readline except:     import pyreadline <\/code><\/pre>\n<p>  <em>\u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u043c\u043e\u0436\u043d\u043e \u0438 \u0432\u043e\u0432\u0441\u0435 \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0431\u0435\u0437 \u044d\u0442\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043e\u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u044e, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f \u0432 \u043d\u0435\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 bash-like \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b.<\/em><\/p>\n<p>  <em>\/config.py<\/em> \u0445\u0440\u0430\u043d\u0438\u0442 \u0432\u0441\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f SQLite, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d\u0430 \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u0430 \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435. \u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0444\u0430\u0439\u043b <em>\/config.py<\/em> \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u043d\u044b\u043c \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0438 \u043f\u0440\u043e\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445.<\/p>\n<pre><code>    import os     _basedir = os.path.abspath(os.path.dirname(__file__))      DEBUG = False      ADMINS = frozenset(['youremail@yourdomain.com'])     SECRET_KEY = 'This string will be replaced with a proper key in production.'      SQLALCHEMY_DATABASE_URI = 'sqlite:\/\/\/' + os.path.join(_basedir, 'app.db')     DATABASE_CONNECT_OPTIONS = {}      THREADS_PER_PAGE = 8      WTF_CSRF_ENABLED = True     WTF_CSRF_SECRET_KEY = &quot;somethingimpossibletoguess&quot;      RECAPTCHA_USE_SSL = False     RECAPTCHA_PUBLIC_KEY = '6LeYIbsSAAAAACRPIllxA7wvXjIE411PfdB2gt2J'     RECAPTCHA_PRIVATE_KEY = '6LeYIbsSAAAAAJezaIq3Ft_hSTo0YtyeFG-JgRtu'     RECAPTCHA_OPTIONS = {'theme': 'white'} <\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><em>_basedir<\/em> \u2014 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u0430\u044f \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f \u0441\u043a\u0440\u0438\u043f\u0442\u0430;<\/li>\n<li><em>DEBUG<\/em> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0430\u0445 \u0432 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0438;<\/li>\n<li><em>SECRET_KEY<\/em> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u0438 cookies, \u043f\u0440\u0438 \u0435\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043b\u043e\u0433\u0438\u043d\u0438\u0442\u044c\u0441\u044f \u0437\u0430\u043d\u043e\u0432\u043e;<\/li>\n<li><em>ADMINS<\/em> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0430\u0434\u0440\u0435\u0441 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043f\u043e\u0447\u0442\u044b \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0441\u0441\u044b\u043b\u043e\u043a \u0438\u0437 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f;<\/li>\n<li><em>SQLALCHEMY_DATABASE_URI<\/em> \u0438 <em>DATABASE_CONNECT_OPTIONS<\/em>, \u043a\u0430\u043a \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u043e \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f \u2014 \u043e\u043f\u0446\u0438\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f SQLAlchemy;<\/li>\n<li><em>THREADS_PER_PAGE<\/em>, \u043a\u0430\u043a \u043c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0441\u0442\u0430\u0432\u0438\u043b 2 \u043d\u0430 \u044f\u0434\u0440\u043e\u2026 \u041c\u043e\u0433\u0443 \u043e\u0448\u0438\u0431\u0430\u0442\u044c\u0441\u044f;<\/li>\n<li><em>WTF_CSRF_ENABLED<\/em> \u0438 <em>WTF_CSRF_SECRET_KEY<\/em> \u0437\u0430\u0449\u0438\u0449\u0430\u044e\u0442 \u043e\u0442 \u043f\u043e\u0434\u043c\u0435\u043d\u044b POST-\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439;<\/li>\n<li><em>RECAPTCHA_*<em> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0432 <strong>WTForms<\/strong> \u043f\u043e\u043b\u044f <strong>RecaptchaField<\/strong>. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0439 \u0438 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \u043a\u043b\u044e\u0447\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 **recaptcha<\/em><\/em>.<\/li>\n<\/ul>\n<p>  <\/p>\n<h2>\u041c\u043e\u0434\u0443\u043b\u044c<\/h2>\n<p>  \u041d\u0430\u0441\u0442\u0440\u043e\u0438\u043c \u043c\u043e\u0434\u0443\u043b\u044c <b>users<\/b> \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435: \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043c\u043e\u0434\u0435\u043b\u0438, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b, \u0434\u0430\u043b\u0435\u0435 \u0444\u043e\u0440\u043c\u0443 \u0438, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u044b.<\/p>\n<h3>\u041c\u043e\u0434\u0435\u043b\u044c<\/h3>\n<p>  <em>\/app\/users\/models.py<\/em>:<\/p>\n<pre><code>    from app import db     from app.users import constants as USER      class User(db.Model):          __tablename__ = 'users_user'         id = db.Column(db.Integer, primary_key=True)         name = db.Column(db.String(50), unique=True)         email = db.Column(db.String(120), unique=True)         password = db.Column(db.String(120))         role = db.Column(db.SmallInteger, default=USER.USER)         status = db.Column(db.SmallInteger, default=USER.NEW)          def __init__(self, name=None, email=None, password=None):           self.name = name           self.email = email           self.password = password          def getStatus(self):           return USER.STATUS[self.status]          def getRole(self):           return USER.ROLE[self.role]          def __repr__(self):             return '&lt;User %r&gt;' % (self.name) <\/code><\/pre>\n<p>  \u0418 \u0435\u0451 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u0432 \u0444\u0430\u0439\u043b\u0435 <em>\/app\/users\/constants.py<\/em>:<\/p>\n<pre><code>    # User role     ADMIN = 0     STAFF = 1     USER = 2     ROLE = {       ADMIN: 'admin',       STAFF: 'staff',       USER: 'user',     }      # user status     INACTIVE = 0     NEW = 1     ACTIVE = 2     STATUS = {       INACTIVE: 'inactive',       NEW: 'new',       ACTIVE: 'active',     }<\/code><\/pre>\n<p>  \u041a \u0441\u043b\u043e\u0432\u0443 \u043e \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430\u0445: \u043c\u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u043c\u043e\u0434\u0443\u043b\u044f. \u041a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043c\u043e\u0434\u0435\u043b\u044f\u0445, \u0444\u043e\u0440\u043c\u0430\u0445 \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u0445, \u0442\u0430\u043a \u0447\u0442\u043e \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0443\u0434\u043e\u0431\u043d\u043e \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u0439\u0442\u0438. \u041a \u0442\u043e\u043c\u0443 \u0436\u0435, \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442 \u043f\u043e\u0434 \u0438\u043c\u0435\u043d\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044f \u0432 \u0432\u0435\u0440\u0445\u043d\u0435\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <em>USERS<\/em> \u0434\u043b\u044f <em>users.constants<\/em>) \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u043e\u0432 \u0438\u043c\u0435\u043d.<\/p>\n<h3>\u0424\u043e\u0440\u043c\u0430<\/h3>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u043e\u0440\u043c\u0443 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0435\u0439.<\/p>\n<p>  \u0424\u043e\u0440\u043c\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0430\u0434\u0440\u0435\u0441 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043f\u043e\u0447\u0442\u044b \u0438 \u043f\u0430\u0440\u043e\u043b\u044c, \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440\u044b \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u0438 \u0432\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u043f\u043e\u043b\u0435 <strong>Recaptcha<\/strong> \u0437\u0430\u0449\u0438\u0442\u0438\u0442 \u043e\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0431\u043e\u0442\u043e\u0432. \u041d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0432\u043d\u0435\u0434\u0440\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0435 \u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u0435, \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043e \u043f\u043e\u043b\u0435 <strong>BooleanField<\/strong> \u0441 \u0438\u043c\u0435\u043d\u0435\u043c <strong>accept_tos<\/strong>. \u0414\u0430\u043d\u043d\u043e\u0435 \u043f\u043e\u043b\u0435 \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u043e, \u043a\u0430\u043a <strong>required<\/strong>, \u0442\u043e \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u044f\u0437\u0430\u043d \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u0444\u043e\u0440\u043c\u043e\u0439 \u0447\u0435\u043a\u0431\u043e\u043a\u0441. \u0424\u043e\u0440\u043c\u0430 \u0432\u0445\u043e\u0434\u0430 \u0441\u043d\u0430\u0431\u0436\u0435\u043d\u0430 \u043f\u043e\u043b\u044f\u043c\u0438 <strong>email<\/strong> \u0438 <strong>password<\/strong> \u0441 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u043c\u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440\u0430\u043c\u0438. <\/p>\n<p>  \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0444\u043e\u0440\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0432 \u0444\u0430\u0439\u043b\u0435 <em>\/app\/users\/forms.py<\/em>:<\/p>\n<pre><code>    from flask.ext.wtf import Form, RecaptchaField     from wtforms import TextField, PasswordField, BooleanField     from wtforms.validators import Required, EqualTo, Email      class LoginForm(Form):       email = TextField('Email address', [Required(), Email()])       password = PasswordField('Password', [Required()])      class RegisterForm(Form):       name = TextField('NickName', [Required()])       email = TextField('Email address', [Required(), Email()])       password = PasswordField('Password', [Required()])       confirm = PasswordField('Repeat Password', [           Required(),           EqualTo('password', message='Passwords must match')           ])       accept_tos = BooleanField('I accept the TOS', [Required()])       recaptcha = RecaptchaField() <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u043b\u044f \u2014 \u0435\u0433\u043e \u043c\u0435\u0442\u043a\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f \u043f\u043e\u043b\u044f <strong>name<\/strong> \u0432 \u0444\u043e\u0440\u043c\u0435 \u0437\u0430\u0434\u0430\u043d\u0430 \u043c\u0435\u0442\u043a\u0430 <strong>NickName<\/strong>. \u0414\u043b\u044f \u043f\u043e\u043b\u0435\u0439 \u0432\u0432\u043e\u0434\u0430 \u043f\u0430\u0440\u043e\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440 <strong>EqualTo<\/strong>, \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0434\u0432\u0443\u0445 \u043f\u043e\u043b\u044f\u0445.<\/p>\n<p>  \u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u043b\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u0445 WTForms \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f <a href=\"http:\/\/wtforms.readthedocs.org\/en\/latest\/\">\u043f\u043e \u044d\u0442\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435<\/a>.<\/p>\n<h3>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435<\/h3>\n<p>  \u0412 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <strong>Blueprint<\/strong> \u2014 \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u0445\u0435\u043c\u044b \u043c\u043e\u0434\u0443\u043b\u044f, \u0432 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u0445 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <strong>url_prefix<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u043b\u044e\u0431\u043e\u0433\u043e URL\u0430, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0432 <strong>route<\/strong>. \u0422\u0430\u043a\u0436\u0435 \u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 \u0444\u043e\u0440\u043c\u044b <strong>form.validate_on_submit<\/strong>, \u0432\u044b\u0434\u0430\u044e\u0449\u0438\u0439 \u0438\u0441\u0442\u0438\u043d\u0443 \u0434\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u0430 HTTP POST \u0438 \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u044b. \u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u0432\u0445\u043e\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043f\u0440\u043e\u0444\u0438\u043b\u044f (<em>\/users\/me<\/em>). \u0414\u043b\u044f \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043d\u0435\u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0432 \u0444\u0430\u0439\u043b\u0435 <em>\/app\/users\/decorators.py<\/em>:<\/p>\n<pre><code>    from functools import wraps      from flask import g, flash, redirect, url_for, request      def requires_login(f):       @wraps(f)       def decorated_function(*args, **kwargs):         if g.user is None:           flash(u'You need to be signed in for this page.')           return redirect(url_for('users.login', next=request.path))         return f(*args, **kwargs)       return decorated_function <\/code><\/pre>\n<p>  \u0414\u0430\u043d\u043d\u044b\u0439 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <strong>g.user<\/strong>. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043d\u0435 \u0437\u0430\u0434\u0430\u043d\u0430, \u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0435 \u0430\u0443\u0442\u0435\u043d\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d, \u0442\u043e\u0433\u0434\u0430 \u0437\u0430\u0434\u0430\u0451\u0442\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0438 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 login (\u0432\u0445\u043e\u0434 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443). \u0414\u0430\u043d\u043d\u044b\u0435 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <strong>g.user<\/strong> \u043f\u043e\u043c\u0435\u0449\u0430\u044e\u0442\u0441\u044f \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <strong>before_request<\/strong>. \u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0435 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043e\u0431\u044a\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u043f\u0440\u043e\u0444\u0438\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f (\u0438\u0441\u0442\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0434\u0440\u0443\u0437\u044c\u044f, \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f) \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u043e\u0435 \u0437\u0430\u043c\u0435\u0434\u043b\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u0411\u0414, \u0442\u0430\u043a \u0447\u0442\u043e \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043c\u043e\u0436\u0435\u0442 \u0440\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 (\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043a\u0430 \u0432\u044b \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u0442\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e \u0438 \u043e\u0447\u0438\u0449\u0430\u0435\u0442\u0435 \u043a\u0435\u0448 \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438). \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u0434 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f <em>\/app\/users\/views.py<\/em>:<\/p>\n<pre><code>    from flask import Blueprint, request, render_template, flash, g, session, redirect, url_for     from werkzeug import check_password_hash, generate_password_hash      from app import db     from app.users.forms import RegisterForm, LoginForm     from app.users.models import User     from app.users.decorators import requires_login      mod = Blueprint('users', __name__, url_prefix='\/users')      @mod.route('\/me\/')     @requires_login     def home():       return render_template(&quot;users\/profile.html&quot;, user=g.user)      @mod.before_request     def before_request():       &quot;&quot;&quot;       pull user's profile from the database before every request are treated       &quot;&quot;&quot;       g.user = None       if 'user_id' in session:         g.user = User.query.get(session['user_id'])      @mod.route('\/login\/', methods=['GET', 'POST'])     def login():       &quot;&quot;&quot;       Login form       &quot;&quot;&quot;       form = LoginForm(request.form)       # make sure data are valid, but doesn't validate password is right       if form.validate_on_submit():         user = User.query.filter_by(email=form.email.data).first()         # we use werzeug to validate user's password         if user and check_password_hash(user.password, form.password.data):           # the session can't be modified as it's signed,            # it's a safe place to store the user id           session['user_id'] = user.id           flash('Welcome %s' % user.name)           return redirect(url_for('users.home'))         flash('Wrong email or password', 'error-message')       return render_template(&quot;users\/login.html&quot;, form=form)      @mod.route('\/register\/', methods=['GET', 'POST'])     def register():       &quot;&quot;&quot;       Registration Form       &quot;&quot;&quot;       form = RegisterForm(request.form)       if form.validate_on_submit():         # create an user instance not yet stored in the database         user = User(name=form.name.data, email=form.email.data, \\           password=generate_password_hash(form.password.data))         # Insert the record in our database and commit it         db.session.add(user)         db.session.commit()          # Log the user in, as he now has an id         session['user_id'] = user.id          # flash will display a message to the user         flash('Thanks for registering')         # redirect user to the 'home' method of the user module.         return redirect(url_for('users.home'))       return render_template(&quot;users\/register.html&quot;, form=form) <\/code><\/pre>\n<p>  <\/p>\n<h2>\u0428\u0430\u0431\u043b\u043e\u043d<\/h2>\n<p>  \u0428\u0430\u0431\u043b\u043e\u043d\u0438\u0437\u0430\u0442\u043e\u0440 <strong>Jinja<\/strong> \u0432\u0441\u0442\u0440\u043e\u0435\u043d \u0432 <strong>Flask<\/strong>. \u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0435\u0433\u043e \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438 (\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u0446\u0438\u043a\u043b\u044b, \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f). \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0448\u0430\u0431\u043b\u043e\u043d <em>\/app\/templates\/base.html<\/em>, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0443\u0442 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u044b. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u043e\u0434\u043d\u043e\u0433\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0442 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 <em>twocolumn.html<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0430\u0441\u043b\u0443\u0434\u0435\u0442\u0441\u044f \u043e\u0442 <em>main.html<\/em>). \u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u0442\u0430\u043a\u0436\u0435 \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 (flash) \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0438\u0437 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <strong>get_flashed_messages<\/strong> \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u0435.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0438 \u043a\u0430\u0436\u0434\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 <em>base.html<\/em> \u043e\u0442\u0440\u0430\u0437\u0438\u0442\u0441\u044f \u043d\u0430 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u0445. \u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u043c\u0438 \u0438\u0445 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438, \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a \u043f\u043e\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d \u0448\u0430\u0431\u043b\u043e\u043d <em>\/app\/templates\/users\/register.html<\/em>:<\/p>\n<pre><code>    &lt;html&gt;       &lt;head&gt;         &lt;title&gt;{% block title %}My Site{% endblock %}&lt;\/title&gt;         {% block css %}         &lt;link rel=&quot;stylesheet&quot; href=&quot;\/static\/css\/reset-min.css&quot; \/&gt;         &lt;link rel=&quot;stylesheet&quot; href=&quot;\/static\/css\/main.css&quot; \/&gt;         {% endblock %}         {% block script %}         &lt;script src=&quot;\/static\/js\/main.js&quot; type=&quot;text\/javascript&quot;&gt;&lt;\/script&gt;         {% endblock %}       &lt;\/head&gt;       &lt;body&gt;         &lt;div id=&quot;header&quot;&gt;{% block header %}{% endblock %}&lt;\/div&gt;         &lt;div id=&quot;messages-wrap&quot;&gt;           &lt;div id=&quot;messages&quot;&gt;             {% for category, msg in get_flashed_messages(with_categories=true) %}               &lt;p class=&quot;message flash-{{ category }}&quot;&gt;{{ msg }}&lt;\/p&gt;             {% endfor %}           &lt;\/div&gt;         &lt;\/div&gt;         &lt;div id=&quot;content&quot;&gt;{% block content %}{% endblock %}&lt;\/div&gt;         &lt;div id=&quot;footer&quot;&gt;{% block footer %}{% endblock %}&lt;\/div&gt;       &lt;\/body&gt;     &lt;\/html&gt; <\/code><\/pre>\n<p>  \u0418 \u0448\u0430\u0431\u043b\u043e\u043d <em>\/app\/templates\/users\/login.html<\/em>:<\/p>\n<pre><code>    {% extends &quot;base.html&quot; %}     {% block content %}       {% from &quot;forms\/macros.html&quot; import render_field %}       &lt;form method=&quot;POST&quot; action=&quot;.&quot; class=&quot;form&quot;&gt;         {{ form.csrf_token }}         {{ render_field(form.email, class=&quot;input text&quot;) }}         {{ render_field(form.password, class=&quot;input text&quot;) }}         &lt;input type=&quot;submit&quot; value=&quot;Login&quot; class=&quot;button green&quot;&gt;       &lt;\/form&gt;       &lt;a href=&quot;{{ url_for('users.register') }}&quot;&gt;Register&lt;\/a&gt;     {% endblock %} <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u043c\u0430\u043a\u0440\u043e\u0441\u044b \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439 html. \u0422\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e\u0442 \u043c\u0430\u043a\u0440\u043e\u0441 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u044f\u0445, \u043e\u043d \u043f\u043e\u043c\u0435\u0449\u0435\u043d \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b <em>\/app\/templates\/forms\/macros.html<\/em>:<\/p>\n<pre><code>    {% macro render_field(field) %}         &lt;div class=&quot;form_field&quot;&gt;         {{ field.label(class=&quot;label&quot;) }}         {% if field.errors %}             {% set css_class = 'has_error ' + kwargs.pop('class', '') %}             {{ field(class=css_class, **kwargs) }}             &lt;ul class=&quot;errors&quot;&gt;{% for error in field.errors %}&lt;li&gt;{{ error|e }}&lt;\/li&gt;{% endfor %}&lt;\/ul&gt;         {% else %}             {{ field(**kwargs) }}         {% endif %}         &lt;\/div&gt;     {% endmacro %} <\/code><\/pre>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0441\u043e\u0437\u0434\u0430\u043d \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d <em>\/app\/templates\/users\/profile.html<\/em>:<\/p>\n<pre><code>   {% extends &quot;base.html&quot; %}    {% block content %}      Hi {{ user.name }}!    {% endblock %} <\/code><\/pre>\n<p>  <\/p>\n<h2>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/h2>\n<p>  \u041a\u0430\u043a \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u043e \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f, \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0444\u0430\u0439\u043b\u0435 <em>\/app\/init.py<\/em>:<\/p>\n<pre><code>    import os     import sys      from flask import Flask, render_template     from flask.ext.sqlalchemy import SQLAlchemy      app = Flask(__name__)     app.config.from_object('config')      db = SQLAlchemy(app)      ########################     # Configure Secret Key #     ########################     def install_secret_key(app, filename='secret_key'):         &quot;&quot;&quot;Configure the SECRET_KEY from a file         in the instance directory.          If the file does not exist, print instructions         to create it from a shell with a random key,         then exit.         &quot;&quot;&quot;         filename = os.path.join(app.instance_path, filename)          try:             app.config['SECRET_KEY'] = open(filename, 'rb').read()         except IOError:             print('Error: No secret key. Create it with:')             full_path = os.path.dirname(filename)             if not os.path.isdir(full_path):                 print('mkdir -p {filename}'.format(filename=full_path))             print('head -c 24 \/dev\/urandom &gt; {filename}'.format(filename=filename))             sys.exit(1)      if not app.config['DEBUG']:         install_secret_key(app)      @app.errorhandler(404)     def not_found(error):         return render_template('404.html'), 404      from app.users.views import mod as usersModule     app.register_blueprint(usersModule)      # Later on you'll import the other blueprints the same way:     #from app.comments.views import mod as commentsModule     #from app.posts.views import mod as postsModule     #app.register_blueprint(commentsModule)     #app.register_blueprint(postsModule) <\/code><\/pre>\n<p>  \u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0411\u0414 SQLAlchemy \u0438 \u043c\u043e\u0434\u0435\u043b\u044c Users \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u0434\u0432\u0443\u0445 \u0440\u0430\u0437\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u0430\u0445, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0430 \u0438\u0437 \u043d\u0438\u0445 \u0432 \u043e\u0431\u0449\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u043c\u0435\u043d \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0442\u0440\u043e\u043a\u0438 <em>from app.users.views import mod as usersModule<\/em>. \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <em>db.create_all()<\/em> \u043d\u0435 \u043f\u0440\u0438\u043d\u0435\u0441\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430.<\/p>\n<p>  \u0410\u043a\u0442\u0438\u0432\u0438\u0440\u0443\u0435\u043c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 virtualenv \u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0411\u0414:<\/p>\n<pre><code>user@Machine:~\/Projects\/dev$ . env\/bin\/activate (env)user@Machine:~\/Projects\/dev$ python shell.py  &gt;&gt;&gt; from app import db &gt;&gt;&gt; db.create_all() &gt;&gt;&gt; exit() <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <em>python run.py<\/em> \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0432\u0438\u0434\u0430:<\/p>\n<pre><code>(env)user@Machine:~\/Projects\/dev$ python run.py   * Running on http:\/\/127.0.0.1:5000\/  * Restarting with reloader <\/code><\/pre>\n<p>  \u041e\u0442\u043a\u0440\u044b\u0432 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u0430\u0434\u0440\u0435\u0441 <a href=\"http:\/\/127.0.0.1:500\/users\/me\/\">http:\/\/127.0.0.1:500\/users\/me\/<\/a> \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u044b \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0432\u0445\u043e\u0434\u0430 \u0438 \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438.       <\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/275099\/\"> http:\/\/habrahabr.ru\/post\/275099\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       <i>\u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f, <a href=\"https:\/\/github.com\/mitsuhiko\/flask\/wiki\/Large-app-how-to\">\u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u043d\u0430\u044f<\/a> \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 Flask \u043d\u0430 GitHub, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043b\u043e\u0434\u043e\u043c \u043a\u043e\u043b\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0442\u0432\u043e\u0440\u0447\u0435\u0441\u0442\u0432\u0430 \u043d\u0435\u0431\u0435\u0437\u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432, \u0430 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u0435\u0451 \u0430\u0432\u0442\u043e\u0440 \u2014 <a href=\"http:\/\/bbrriiccee@gmail.com\">Brice Leroy<\/a>. \u041e\u043d\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439 \u0434\u043b\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0445 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u043f\u043e Flask. \u041b\u0438\u0447\u043d\u043e \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u043e\u043d \u0441\u0442\u0430\u043b \u043e\u0442\u0432\u0435\u0442\u043e\u043c \u043d\u0430 \u043c\u043d\u043e\u0433\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u044b\u043b \u00ab\u043a\u0430\u043a \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442\u00bb.<\/p>\n<p>  \u0414\u043b\u044f \u0445\u043e\u0442\u044c \u0441\u043a\u043e\u043b\u044c\u043a\u043e-\u0442\u043e \u043e\u043f\u044b\u0442\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432 \u043e\u043d\u0430 \u0432\u0440\u044f\u0434 \u043b\u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u0430, \u043c\u043d\u043e\u0433\u0438\u0435 \u043c\u043e\u0433\u0443\u0442 \u0432\u043e\u0432\u0441\u0435 \u043d\u0435 \u0441\u043e\u0433\u043b\u0430\u0441\u0438\u0442\u044c\u0441\u044f \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430\u043c\u0438, \u043e\u0434\u043d\u0430\u043a\u043e \u0434\u043b\u044f \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0445\u0441\u044f \u043d\u0430 \u0440\u0430\u043d\u043d\u0435\u0439 \u0441\u0442\u0430\u0434\u0438\u0438 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0442\u044c \u0442\u043e\u043b\u0447\u043a\u043e\u043c \u043a \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044e, \u043a\u0430\u043a \u0441\u0442\u0430\u043b\u0430 \u0434\u043b\u044f \u043c\u0435\u043d\u044f. \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0441\u0434\u0435\u043b\u0430\u043b \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u0438\u0439 \u044f\u0437\u044b\u043a \u2014 \u0443 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043e\u0447\u0435\u043d\u044c \u043d\u0438\u0437\u043a\u0438\u0439 \u043f\u043e\u0440\u043e\u0433 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0438 \u0441\u0442\u043e\u0438\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u0435\u0449\u0435 \u043d\u0438\u0436\u0435.<\/p>\n<p>  \u041e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u043d\u0430 Python 3.5, Flask 0.10, Flask-SQLAlchemy 2.1, Flask-WTG 0.9.<\/i>  <\/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-272124","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/272124","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=272124"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/272124\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=272124"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=272124"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=272124"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}