{"id":374828,"date":"2024-05-21T06:09:54","date_gmt":"2024-05-21T06:09:54","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=374828"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=374828","title":{"rendered":"<span>\u041e\u0442 \u043a\u043e\u0434\u0430 \u0434\u043e \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430: \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 Python Flask \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u044b\u0434\u0430\u0447\u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432<\/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<p>\u041f\u0440\u0438\u0432\u0435\u0442 \u0432\u0441\u0435\u043c! \u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0414\u043c\u0438\u0442\u0440\u0438\u0439. \u042f \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439 \u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439 \u0434\u043b\u044f \u0432\u0430\u0441(\u043d\u0435 \u043f\u0438\u043d\u0430\u0439\u0442\u0435 \u0441\u0438\u043b\u044c\u043d\u043e, \u043f\u0435\u0440\u0432\u044b\u0439 \u043e\u043f\u044b\u0442, \u043c\u044b\u0441\u043b\u0438 \u043f\u0443\u0442\u0430\u044e\u0442\u0441\u044f). \u0422\u0435\u043c\u0430 \u043c\u043e\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u2014 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 Python Flask \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u044b\u0434\u0430\u0447\u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u0438 \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u0438\u043b\u0441\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0435\u0435 \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u044f <a href=\"https:\/\/habr.com\/ru\/companies\/tensor\/articles\/807203\/\" rel=\"noopener noreferrer nofollow\">\u041f\u043e\u0447\u0442\u0430 \u0431\u0435\u0437 \u0445\u043b\u043e\u043f\u043e\u0442: \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043f\u0438\u0441\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Python<\/a><\/p>\n<p>\u0412 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c \u043c\u0438\u0440\u0435 \u0432\u0441\u0451 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0436\u0438\u0437\u043d\u044c \u043b\u044e\u0434\u0435\u0439 \u0438 \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0440\u0443\u0442\u0438\u043d\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447. \u041e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u044b\u0434\u0430\u0447\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432. \u0420\u0430\u043d\u044c\u0448\u0435 \u0432 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0433\u0434\u0435 \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u043e\u043d\u0438 \u0432\u044b\u0434\u0430\u0432\u0430\u043b\u0438\u0441\u044c \u0432 \u0431\u0443\u043c\u0430\u0436\u043d\u043e\u043c \u0432\u0438\u0434\u0435, \u043d\u043e \u0441 \u043f\u0440\u0438\u0445\u043e\u0434\u043e\u043c COVID-19 \u043a\u043e\u0433\u0434\u0430 \u0443\u0448\u043b\u0438 \u043d\u0430 \u0434\u0438\u0441\u0442\u0430\u043d\u0442, \u0438 \u0432\u0441\u0435 \u043a\u0443\u0440\u0441\u044b \u0431\u044b\u043b\u0438 \u0434\u0438\u0441\u0442\u0430\u043d\u0446\u0438\u043e\u043d\u043d\u043e \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043a\u0440\u0438\u043f\u0442 \u0430 \u043f\u043e\u0442\u043e\u043c \u0438 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 \u0432\u0435\u0431 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c \u0434\u043b\u044f \u0440\u0430\u0441\u0441\u044b\u043b\u043a\u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 Python\/Flask, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0432\u044b\u0434\u0430\u0447\u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432. \u0420\u0430\u0441\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043e\u0441\u043d\u043e\u0432\u044b \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u0441 \u0440\u0430\u0437\u0443 \u043a \u0434\u0435\u043b\u0443, \u043f\u043e\u0445\u043e\u0434\u0443 \u0431\u0443\u0434\u0443 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0443\u0441\u043a\u0438 \u043a\u043e\u0434\u0430.<\/p>\n<p>\u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043e\u043d\u0430 \u0442\u0430\u043a:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/197\/a70\/aab\/197a70aab98d6669a252fb654497e985.png\" alt=\"\u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0438 \u0431\u0435\u0437 \u0440\u0430\u0434\u0438\u043e\u043a\u043d\u043e\u043f\u043a\u0438 &quot;\u0421\u0432\u0438\u0434\u0435\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e&quot;, \u043d\u043e \u0442\u043a \u044f \u043f\u0438\u0441\u0430\u043b \u0441 \u043f\u0435\u0440\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u043e\u0439 \u043d\u0430 \u0442\u043e \u0447\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0434\u0430\u0447\u0430 \u0438 \u0443\u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u0435\u043d\u0438\u0439 \u043e\u043d\u0430 \u0442\u0443\u0442 \u043e\u0441\u0442\u0430\u043b\u0430\u0441\u044c, \u0442\u0435\u043a\u0441\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043e\u043d \u043f\u043e\u043f\u0430\u0434\u0451\u0442 \u0432 \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u0438\u0441\u044c\u043c\u0430 \u043e \u043d\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u0434\u0430\u043b\u044c\u0448\u0435.\" title=\"\u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0438 \u0431\u0435\u0437 \u0440\u0430\u0434\u0438\u043e\u043a\u043d\u043e\u043f\u043a\u0438 &quot;\u0421\u0432\u0438\u0434\u0435\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e&quot;, \u043d\u043e \u0442\u043a \u044f \u043f\u0438\u0441\u0430\u043b \u0441 \u043f\u0435\u0440\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u043e\u0439 \u043d\u0430 \u0442\u043e \u0447\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0434\u0430\u0447\u0430 \u0438 \u0443\u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u0435\u043d\u0438\u0439 \u043e\u043d\u0430 \u0442\u0443\u0442 \u043e\u0441\u0442\u0430\u043b\u0430\u0441\u044c, \u0442\u0435\u043a\u0441\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043e\u043d \u043f\u043e\u043f\u0430\u0434\u0451\u0442 \u0432 \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u0438\u0441\u044c\u043c\u0430 \u043e \u043d\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u0434\u0430\u043b\u044c\u0448\u0435.\" width=\"682\" height=\"552\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/197\/a70\/aab\/197a70aab98d6669a252fb654497e985.png\"\/><\/p>\n<div><figcaption>\u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0438 \u0431\u0435\u0437 \u0440\u0430\u0434\u0438\u043e\u043a\u043d\u043e\u043f\u043a\u0438 &#171;\u0421\u0432\u0438\u0434\u0435\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e&#187;, \u043d\u043e \u0442\u043a \u044f \u043f\u0438\u0441\u0430\u043b \u0441 \u043f\u0435\u0440\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u043e\u0439 \u043d\u0430 \u0442\u043e \u0447\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0434\u0430\u0447\u0430 \u0438 \u0443\u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u0435\u043d\u0438\u0439 \u043e\u043d\u0430 \u0442\u0443\u0442 \u043e\u0441\u0442\u0430\u043b\u0430\u0441\u044c, \u0442\u0435\u043a\u0441\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043e\u043d \u043f\u043e\u043f\u0430\u0434\u0451\u0442 \u0432 \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u0438\u0441\u044c\u043c\u0430 \u043e \u043d\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u0434\u0430\u043b\u044c\u0448\u0435.<\/figcaption><\/div>\n<\/figure>\n<p>\u041d\u0430 \u0432\u0445\u043e\u0434 \u044f \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043e\u0442 \u043a\u0443\u0440\u0430\u0442\u043e\u0440\u0430 \u043a\u0443\u0440\u0441\u0430 \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0442\u043e\u043b\u0431\u0446\u044b: <\/p>\n<ul>\n<li>\n<p>\u041d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0435\u0440\u043e\u043f\u0440\u0438\u044f\u0442\u0438\u044f <\/p>\n<\/li>\n<li>\n<p>\u0414\u0430\u0442\u0430 \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f <\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u044a\u0451\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b <\/p>\n<\/li>\n<li>\n<p>\u0424\u0430\u043c\u0438\u043b\u0438\u044f<\/p>\n<\/li>\n<li>\n<p>\u0418\u043c\u044f <\/p>\n<\/li>\n<li>\n<p>\u041e\u0442\u0447\u0435\u0441\u0442\u0432\u043e <\/p>\n<\/li>\n<li>\n<p>E\u2011mail <\/p>\n<\/li>\n<li>\n<p>\u0414\u0430\u0442\u0430 \u0432\u044b\u0434\u0430\u0447\u0438<\/p>\n<\/li>\n<li>\n<p>\u0421\u0442\u0430\u0442\u0443\u0441 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f <\/p>\n<\/li>\n<li>\n<p>\u041a\u0443\u0440\u0430\u0442\u043e\u0440 \u0424\u0418\u041e<\/p>\n<\/li>\n<li>\n<p>\u041a\u0443\u0440\u0430\u0442\u043e\u0440 \u0422\u0415\u041b <\/p>\n<\/li>\n<li>\n<p>\u041a\u0443\u0440\u0430\u0442\u043e\u0440 E\u2011MAIL<\/p>\n<\/li>\n<\/ul>\n<p>\u0424\u0430\u0439\u043b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f app.py<\/p>\n<pre><code class=\"python\">import os from flask import Flask, request, render_template  from parse_table import table_courses from html2pdf import table_cert, tamplate_html from send_mail import collection_info  UPLOAD_FOLDER = 'upload\/' app = Flask(__name__)  app.config['FILE_UPLOADS'] = UPLOAD_FOLDER  @app.route('\/certificate', methods=['GET', 'POST']) def cert():     if request.method == 'POST':         # \u0428\u0430\u0431\u043b\u043e\u043d \u043f\u0438\u0441\u044c\u043c\u0430         template_email = 'templates\/sample_mail\/sample_edu_doc.html'         # \u0422\u0435\u043c\u0430 \u043f\u0438\u0441\u044c\u043c\u0430         subject_email = request.form['subject_email']         # \u0422\u0435\u043a\u0441\u0442 \u043f\u0438\u0441\u044c\u043c\u0430         text_email = request.form['text_email']         # \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u0424\u0418\u041e \u0438 \u0430\u0434\u0440\u0435\u0441\u0430\u043c\u0438         table_email = request.files['table_email']         table_email.save(os.path.join(app.config['FILE_UPLOADS'], table_email.filename))         list_email = table_cert(table_email)         # print(list_email)         cert_list = tamplate_html(list_email)         ok_list, err_list = collection_info(template_email,                                             subject_email,                                             list_email=list_email,                                             file_name=cert_list)         return render_template('list_spam.html', ok_list=ok_list, err_list=err_list)     else:         return render_template('dokuments.html')   if __name__ == '__main__':     app.run()<\/code><\/pre>\n<p>\u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 cert \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u043b\u043e\u0433\u0438\u043a\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443, \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u0438\u0441\u044c\u043c\u0430, \u0442\u0435\u043c\u0443, \u0442\u0435\u043a\u0441\u0442 \u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0434\u0430\u043b\u044c\u0448\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0444\u0430\u0439\u043b\u0435 html2pdf.py <\/p>\n<pre><code class=\"python\">import pandas as pd   list_col = ['\u041d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0435\u0440\u043e\u043f\u0440\u0438\u044f\u0442\u0438\u044f',             '\u0414\u0430\u0442\u0430 \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f',             '\u041e\u0431\u044a\u0451\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b',             '\u0424\u0430\u043c\u0438\u043b\u0438\u044f', '\u0418\u043c\u044f', '\u041e\u0442\u0447\u0435\u0441\u0442\u0432\u043e',             'E-mail',             '\u0414\u0430\u0442\u0430 \u0432\u044b\u0434\u0430\u0447\u0438',             '\u0421\u0442\u0430\u0442\u0443\u0441 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f',             '\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440',             '\u041a\u0443\u0440\u0430\u0442\u043e\u0440 \u0424\u0418\u041e','\u041a\u0443\u0440\u0430\u0442\u043e\u0440 \u0422\u0415\u041b','\u041a\u0443\u0440\u0430\u0442\u043e\u0440 E-MAIL']  def table_cert(file):     table = pd.read_excel(file)     df = pd.DataFrame(table)     table_value = df[list_col].values     # print(table_value)     cert_values = []     for i in table_value:         cert_value = {}         cert_value['event_name'] = i[0]         cert_value['event_date'] = i[1]         cert_value['program_size'] = i[2]         cert_value['surname'] = i[3]         cert_value['name'] = i[4]         cert_value['second_name'] = i[5]         cert_value['email'] = i[6]         cert_value['date_of_issue'] = i[7]         cert_value['status'] = i[8]         cert_value['reg_number'] = i[9]         cert_value['kyrator'] = i[10]         cert_value['kyrator_tel'] = i[11]         cert_value['kyrator_email'] = i[12]         cert_value['cert_file'] = f'{i[3]}{i[4]}{i[5]}_cert.pdf'         cert_values.append(cert_value)     return cert_values  import pdfkit  def html2pdf(name):     path_wkthmltopdf = b'wkhtmltopdf\\\\bin\\wkhtmltopdf.exe'     config = pdfkit.configuration(wkhtmltopdf=path_wkthmltopdf)     css = b'templates\/cert\/style_new.css'     options = {         'orientation': 'Portrait',         'page-size':'A5',         'margin-bottom': '0mm',         'margin-left': '0mm',         'margin-right': '0mm',         'margin-top': '0mm',         # 'page-width': '7.12in',     }     try:         pdfkit.from_file(f'{name}.html',                          f'{name}_cert.pdf',                          configuration=config,                          options=options, css=css)     except OSError:         pass  from jinja2 import Template import base64  def image_file_path_to_base64_string(filepath: str) -> str:     with open(filepath, 'rb') as f:         return base64.b64encode(f.read()).decode()  def tamplate_html(table):     name_cert_list = []     for cert_html in table:         context = {             'img_fon': image_file_path_to_base64_string('static\/cert\/new_fon.png'),             'img_director': image_file_path_to_base64_string('static\/cert\/\u043f\u043e\u0434\u043f\u0438\u0441\u044c.png'),             'img_pechat': image_file_path_to_base64_string('static\/cert\/\u043f\u0435\u0447\u0430\u0442\u044c.png'),              'surname': cert_html.get('surname'),             'name': cert_html.get('name'),             'second_name': cert_html.get('second_name'),             'date': cert_html.get('event_date'),             'subject':  cert_html.get('event_name'),             'time': cert_html.get('program_size'),             'number': cert_html.get('reg_number'),             'date_in': cert_html.get('date_of_issue')         }         # print(context)         html = open('templates\/cert\/index_new.html', encoding='utf-8').read()         tmp = Template(html)         out_file = tmp.render(context)         name_file = f\"{cert_html.get('surname')}{cert_html.get('name')}{cert_html.get('second_name')}\"         with open(name_file+'.html', 'w', encoding='utf-8') as f:             f.write(out_file)             f.close()         html2pdf(name_file)         name_cert_list.append(f'{name_file}_cert.pdf')     return name_cert_list <\/code><\/pre>\n<p>\u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 table_cert \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e pandas \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0438\u0437 \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439 \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0438\u0445 \u0432 \u0441\u0435\u0431\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u044f \u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430.<\/p>\n<p>\u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 html2pdf \u0437\u0430\u0434\u0430\u044e\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0431\u0443\u0434\u0443\u0449\u0435\u0433\u043e \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430: \u0440\u0430\u0437\u043c\u0435\u0440, \u043e\u0442\u0441\u0442\u0443\u043f\u044b, \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u044f, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u0443\u0442\u0438 \u0434\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430(\u043e\u043d \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 pdfkit) \u0438 \u043f\u0443\u0442\u044c \u043a CSS \u0444\u0430\u0439\u043b\u0443 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0443\u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 image_file_path_to_base64_string \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0442\u043a \u0431\u0435\u0437 \u044d\u0442\u043e\u0433\u043e \u043e\u043d\u043e \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p>\u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 tamplate_html \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f html \u0448\u0430\u0431\u043b\u043e\u043d \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u0438 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 .pdf \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044f \u0432\u0441\u0435 \u044d\u0442\u043e \u0432 \u0441\u043f\u0438\u0441\u043e\u043a.<\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u0441\u043f\u0438\u0441\u043a\u0438 \u0433\u043e\u0442\u043e\u0432\u044b, \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u0432\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435  ok_list, err_list \u043e\u043d\u0438 \u043f\u043e\u0441\u043b\u0443\u0436\u0430\u0442 \u043f\u0440\u0438 \u0432\u044b\u0432\u043e\u0434\u0435 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432 \u0432\u0435\u0431 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 \u0432 \u0434\u0432\u0435 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439, \u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0435 \u0432\u044b\u0448\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e collection_info.<\/p>\n<pre><code class=\"python\">import re import os  from config import PORT, SERVER, LOGIN, PWD  import smtplib  from email.mime.application import MIMEApplication from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from email.mime.base import MIMEBase from email import encoders from email.header import Header from email.utils import formataddr  from bs4 import BeautifulSoup from jinja2 import Template   def collection_info(template, subject, list_email, **params):     ok_list, err_list = [], []     for email in list_email:         ok, error = send_email(template,                                subject,                                email.get('email'),                                first_name=email.get('name'),                                second_name=email.get('second_name'),                                cert_name=email.get('cert_file'),                                kyrator=email.get('kyrator'),                                kyrator_tel=email.get('kyrator_tel'),                                kyrator_email=email.get('kyrator_email'),                                **params)         ok_list.append(ok)         err_list.append(error)     return ok_list, err_list  def send_email(template, subject, email, **params):     server = smtplib.SMTP_SSL(SERVER, PORT)     server.login(LOGIN, PWD)     print(f'\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f email: {email}')     print(f'\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f params: {params}')     msg = MIMEMultipart()     msg['From'] = LOGIN     msg['To'] = email     msg['Subject'] = Header(subject, 'utf-8')     html = open(template, encoding='utf-8').read()     template_html = Template(html).render(subject_email=subject,                                           first_name=params.get('first_name'),                                           second_name=params.get('second_name'),                                           text_email=params.get('text_email'),                                           link_form=params.get('link_form'),                                           link_teacher=params.get('link_teacher'),                                            kyrator=params.get('kyrator'),                                           kyrator_tel=params.get('kyrator_tel'),                                           kyrator_email=params.get('kyrator_email'),                                           )     body = BeautifulSoup(template_html, 'html.parser')     msg.attach(MIMEText(body, 'html', 'utf-8'))  # \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0435\u0441\u043b\u0438 \u0432\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0435\u0441\u0442\u044c \u0434\u043e \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u044f\u0435\u043c \u043a \u043f\u0438\u0441\u044c\u043c\u0443     name_attachment = params.get('file_email')     cert_attachment = params.get('cert_name')     if name_attachment:         file_attachment = os.path.basename(name_attachment.filename)         open_attach = MIMEApplication(open('upload\/'+name_attachment.filename, 'rb').read())         encoders.encode_base64(open_attach)         open_attach.add_header('Content-Disposition', 'attachment', filename=file_attachment)         msg.attach(open_attach)     elif cert_attachment:         print(cert_attachment)         open_attach = MIMEApplication(open(cert_attachment, 'rb').read())         encoders.encode_base64(open_attach)         open_attach.add_header('Content-Disposition', 'attachment', filename=cert_attachment)         msg.attach(open_attach)       ok, error = [],[]     try:         server.sendmail(LOGIN, msg['To'], msg.as_string())         server.quit()         ok = f\"{msg['To']} - OK\"     except BaseException as err:         e = re.search('\\(([^)]+)', str(err)).group(1)         server.quit()         error = f\"{msg['To']} - {e}\"     return ok, error<\/code><\/pre>\n<p>\u0418\u0437 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044e\u0442\u0441\u044f html \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u0438 \u0440\u0430\u0441\u0441\u044b\u043b\u0430\u044e\u0442\u0441\u044f \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0430\u043c \u0441 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0439 \u043f\u043e\u0447\u0442\u044b, \u0438 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0434\u0432\u0430 \u0441\u043f\u0438\u0441\u043a\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u0432\u044b\u0432\u0435\u0434\u0443\u0442\u0441\u044f \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u0432 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439 \u0438\u043b\u0438 \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u043e\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438.<\/p>\n<p>\u0428\u0430\u0431\u043b\u043e\u043d \u043f\u0438\u0441\u044c\u043c\u0430<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a14\/604\/a1f\/a14604a1f7d38d869481f7e33e3c4965.png\" alt=\"\u043a\u043e\u0434 \u043f\u043e\u0434 \u0441\u043f\u043e\u0439\u043b\u0435\u0440\u043e\u043c\" title=\"\u043a\u043e\u0434 \u043f\u043e\u0434 \u0441\u043f\u043e\u0439\u043b\u0435\u0440\u043e\u043c\" width=\"581\" height=\"724\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a14\/604\/a1f\/a14604a1f7d38d869481f7e33e3c4965.png\"\/><\/p>\n<div><figcaption>\u043a\u043e\u0434 \u043f\u043e\u0434 \u0441\u043f\u043e\u0439\u043b\u0435\u0440\u043e\u043c<\/figcaption><\/div>\n<\/figure>\n<details class=\"spoiler\">\n<summary>Hidden text<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"xml\">&lt;!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\"> &lt;html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">  &lt;head>     &lt;meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\"\/>     &lt;meta name=\"viewport\" content=\"width=device-width\"\/>      &lt;!-- For development, pass document through inliner -->     &lt;!-- &lt;link rel=\"stylesheet\" href=\"css\/simple.css\">-->      &lt;style type=\"text\/css\">         \/* Your custom styles go here *\/         * {             margin: 0;             padding: 0;             font-size: 100%;             font-family: 'Avenir Next', \"Helvetica Neue\", \"Helvetica\", Helvetica, Arial, sans-serif;             line-height: 1.65;         }          img {             max-width: 100%;             margin: 0 auto;             display: block;         }          body,         .body-wrap {             width: 100% !important;             height: 100%;             background: #f8f8f8;         }          a {             color: #71bc37;             text-decoration: none;         }          a:hover {             text-decoration: underline;         }          .text-center {             text-align: center;         }          .text-right {             text-align: right;         }          .text-left {             text-align: left;         }          .button {             display: inline-block;             color: #fff;             background: #71bc37;             border: solid #71bc37;             border-width: 10px 20px 8px;             font-weight: bold;             border-radius: 4px;         }          .button:hover {             text-decoration: none;         }          h1,         h2,         h3,         h4,         h5,         h6 {             margin-bottom: 20px;             line-height: 1.25;         }          h1 {             font-size: 32pt;         }          h2 {             font-size: 28pt;         }          h3 {             font-size: 24pt;         }          h4 {             font-size: 20pt;         }          h5 {             font-size: 16pt;         }          p,         ul,         ol {             font-size: 14pt;             font-weight: normal;             margin-bottom: 20px;         }          .container {             display: block !important;             clear: both !important;             margin: 0 auto !important;             max-width: 580px !important;         }          .container table {             width: 100% !important;             border-collapse: collapse;         }          .container .masthead {             padding: 50px 0;             background: #71bc37;             color: white;         }          .container .masthead h1 {             margin: 0 auto !important;             max-width: 90%;             text-transform: uppercase;         }          .container .content {             background: white;             padding: 30px 35px;         }          .container .content.footer {             background: none;         }          .container .content.footer p {             margin-bottom: 0;             color: #888;             text-align: center;             font-size: 14px;         }          .container .content.footer a {             color: #888;             text-decoration: none;             font-weight: bold;         }          .container .content.footer a:hover {             text-decoration: underline;         }     &lt;\/style> &lt;\/head>  &lt;body> &lt;table class=\"body-wrap\">     &lt;tr>         &lt;td class=\"container\">             &lt;!-- Message start -->             &lt;table>                 &lt;tr>                     &lt;td align=\"center\" class=\"masthead\">                         &lt;!--                        &lt;h1>Something Big...&lt;\/h1>-->                     &lt;\/td>                 &lt;\/tr>                 &lt;tr>                     &lt;td class=\"content\">                         &lt;h2>\u0423\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0439(\u0430\u044f) {{ first_name }} {{ second_name }}!&lt;\/h2>                         &lt;p>\u041d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c &lt;b>{{ subject_email }}&lt;\/b>. &lt;\/p>                          {% if text_email != None %}                         &lt;p>{{ text_email }}&lt;\/p>                         {% else %}                         {% endif %}                          &lt;p>\u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043e\u0441\u0442\u0430\u043b\u0438\u0441\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b, \u043e\u0431\u0440\u0430\u0449\u0430\u0439\u0442\u0435\u0441\u044c \u043a \u043a\u0443\u0440\u0430\u0442\u043e\u0440\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. &lt;\/p>                         &lt;p>\u041a\u0443\u0440\u0430\u0442\u043e\u0440: {{ kyrator }}&lt;\/p>                         &lt;p>\u0422\u0435\u043b\u0435\u0444\u043e\u043d: {{ kyrator_tel }}&lt;\/p>                         &lt;p>E-mail &lt;a href=\"mailto:{{ kyrator_email }}\">{{ kyrator_email }}&lt;\/a>&lt;\/p>                         &lt;br>                          &lt;hr>                         &lt;p style=\"margin: 0\">&lt;i>\u0414\u0430\u043d\u043d\u043e\u0435 \u043f\u0438\u0441\u044c\u043c\u043e \u0431\u044b\u043b\u043e \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438.&lt;\/i>&lt;\/p>                         &lt;p style=\"margin: 0\">&lt;i>\u041f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u043d\u0435 \u043e\u0442\u0432\u0435\u0447\u0430\u0439\u0442\u0435 \u043d\u0430 \u043d\u0435\u0433\u043e. \u042d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441 **** \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0430\u0434\u0440\u0435\u0441\u043e\u043c \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u043a\u0438&lt;\/i>&lt;\/p>                      &lt;\/td>                 &lt;\/tr>             &lt;\/table>         &lt;\/td>     &lt;\/tr> &lt;\/table> &lt;\/body>  &lt;\/html><\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0428\u0430\u0431\u043b\u043e\u043d \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430<\/p>\n<pre><code class=\"css\">&lt;!DOCTYPE html>  &lt;html lang=\"ru\">  &lt;head>     &lt;meta charset=\"UTF-8\">     &lt;title>Title&lt;\/title>     &lt;link rel=\"stylesheet\" href=\"style_new.css\">  &lt;\/head>  &lt;body>     &lt;div class=\"container\">         &lt;div class=\"image\">              &lt;img src=\"data:image\/png;base64,{{ img_fon }}\">          &lt;\/div>         &lt;div class=\"text\">             &lt;div class=\"q1\">                 &lt;p>************&lt;\/p>             &lt;\/div>             &lt;div class=\"q2\">                 &lt;p>*************&lt;\/p>             &lt;\/div>             &lt;!--             &lt;div class=\"q3\">                 &lt;p>*****************&lt;\/p>             &lt;\/div> -->             &lt;div class=\"q4\">                 &lt;p>\u0421\u0415\u0420\u0422\u0418\u0424\u0418\u041a\u0410\u0422&lt;\/p>             &lt;\/div>              &lt;div class=\"q6\">                 {% if second_name == 'nan' %}                     &lt;p>{{ surname }} {{ name }}&lt;\/p>                 {% else %}                     &lt;p>{{ surname }} {{ name }} {{ second_name }} &lt;\/p>                 {% endif %}             &lt;\/div>              &lt;div class=\"q8\">                  &lt;p>{{ date }} \u043f\u0440\u0438\u043d\u044f\u043b(\u0430) \u0443\u0447\u0430\u0441\u0442\u0438\u0435 \u0432&lt;\/p>                    &lt;p>{{ subject }}&lt;\/p>                   &lt;p>\u0432 \u043e\u0431\u044a\u0451\u043c\u0435 {{ time }} \u0430\u043a\u0430\u0434\u0435\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0447\u0430\u0441\u043e\u0432&lt;\/p>              &lt;\/div>             &lt;div class=\"q11\">                 &lt;p>\u041c.\u041f.&lt;\/p>                 &lt;p>\u0414\u0438\u0440\u0435\u043a\u0442\u043e\u0440 _______________ \u0438.\u0418. \u0418\u0432\u0430\u043d\u043e\u0432&lt;\/p>              &lt;\/div>             &lt;div class=\"podpis_pechat\">                                  &lt;img src=\"data:image\/png;base64,{{ img_director }}\">                                 &lt;img src=\"data:image\/png;base64,{{ img_pechat }}\">             &lt;\/div>             &lt;div class=\"q12\">                 &lt;p>\u0433. \u042f\u0440\u043e\u0441\u043b\u0430\u0432\u043b\u044c &lt;\/p>                 &lt;p>{{ date_in }} &lt;\/p>              &lt;\/div>         &lt;\/div>     &lt;\/div> &lt;\/body>&lt;\/html> <\/code><\/pre>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0432\u0440\u043e\u0434\u0435 \u0412\u0421\u0401<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/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\/articles\/810757\/\"> https:\/\/habr.com\/ru\/articles\/810757\/<\/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<p>\u041f\u0440\u0438\u0432\u0435\u0442 \u0432\u0441\u0435\u043c! \u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0414\u043c\u0438\u0442\u0440\u0438\u0439. \u042f \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439 \u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439 \u0434\u043b\u044f \u0432\u0430\u0441(\u043d\u0435 \u043f\u0438\u043d\u0430\u0439\u0442\u0435 \u0441\u0438\u043b\u044c\u043d\u043e, \u043f\u0435\u0440\u0432\u044b\u0439 \u043e\u043f\u044b\u0442, \u043c\u044b\u0441\u043b\u0438 \u043f\u0443\u0442\u0430\u044e\u0442\u0441\u044f). \u0422\u0435\u043c\u0430 \u043c\u043e\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u2014 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 Python Flask \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u044b\u0434\u0430\u0447\u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u0438 \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u0438\u043b\u0441\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0435\u0435 \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u044f <a href=\"https:\/\/habr.com\/ru\/companies\/tensor\/articles\/807203\/\" rel=\"noopener noreferrer nofollow\">\u041f\u043e\u0447\u0442\u0430 \u0431\u0435\u0437 \u0445\u043b\u043e\u043f\u043e\u0442: \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043f\u0438\u0441\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Python<\/a><\/p>\n<p>\u0412 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c \u043c\u0438\u0440\u0435 \u0432\u0441\u0451 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0436\u0438\u0437\u043d\u044c \u043b\u044e\u0434\u0435\u0439 \u0438 \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0440\u0443\u0442\u0438\u043d\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447. \u041e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u044b\u0434\u0430\u0447\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432. \u0420\u0430\u043d\u044c\u0448\u0435 \u0432 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0433\u0434\u0435 \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u043e\u043d\u0438 \u0432\u044b\u0434\u0430\u0432\u0430\u043b\u0438\u0441\u044c \u0432 \u0431\u0443\u043c\u0430\u0436\u043d\u043e\u043c \u0432\u0438\u0434\u0435, \u043d\u043e \u0441 \u043f\u0440\u0438\u0445\u043e\u0434\u043e\u043c COVID-19 \u043a\u043e\u0433\u0434\u0430 \u0443\u0448\u043b\u0438 \u043d\u0430 \u0434\u0438\u0441\u0442\u0430\u043d\u0442, \u0438 \u0432\u0441\u0435 \u043a\u0443\u0440\u0441\u044b \u0431\u044b\u043b\u0438 \u0434\u0438\u0441\u0442\u0430\u043d\u0446\u0438\u043e\u043d\u043d\u043e \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043a\u0440\u0438\u043f\u0442 \u0430 \u043f\u043e\u0442\u043e\u043c \u0438 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 \u0432\u0435\u0431 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c \u0434\u043b\u044f \u0440\u0430\u0441\u0441\u044b\u043b\u043a\u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 Python\/Flask, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0432\u044b\u0434\u0430\u0447\u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432. \u0420\u0430\u0441\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043e\u0441\u043d\u043e\u0432\u044b \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u0441 \u0440\u0430\u0437\u0443 \u043a \u0434\u0435\u043b\u0443, \u043f\u043e\u0445\u043e\u0434\u0443 \u0431\u0443\u0434\u0443 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0443\u0441\u043a\u0438 \u043a\u043e\u0434\u0430.<\/p>\n<p>\u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043e\u043d\u0430 \u0442\u0430\u043a:<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0438 \u0431\u0435\u0437 \u0440\u0430\u0434\u0438\u043e\u043a\u043d\u043e\u043f\u043a\u0438 &#171;\u0421\u0432\u0438\u0434\u0435\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e&#187;, \u043d\u043e \u0442\u043a \u044f \u043f\u0438\u0441\u0430\u043b \u0441 \u043f\u0435\u0440\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u043e\u0439 \u043d\u0430 \u0442\u043e \u0447\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0434\u0430\u0447\u0430 \u0438 \u0443\u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u0435\u043d\u0438\u0439 \u043e\u043d\u0430 \u0442\u0443\u0442 \u043e\u0441\u0442\u0430\u043b\u0430\u0441\u044c, \u0442\u0435\u043a\u0441\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043e\u043d \u043f\u043e\u043f\u0430\u0434\u0451\u0442 \u0432 \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u0438\u0441\u044c\u043c\u0430 \u043e \u043d\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u0434\u0430\u043b\u044c\u0448\u0435.<\/figcaption><\/div>\n<\/figure>\n<p>\u041d\u0430 \u0432\u0445\u043e\u0434 \u044f \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043e\u0442 \u043a\u0443\u0440\u0430\u0442\u043e\u0440\u0430 \u043a\u0443\u0440\u0441\u0430 \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0442\u043e\u043b\u0431\u0446\u044b: <\/p>\n<ul>\n<li>\n<p>\u041d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0435\u0440\u043e\u043f\u0440\u0438\u044f\u0442\u0438\u044f <\/p>\n<\/li>\n<li>\n<p>\u0414\u0430\u0442\u0430 \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f <\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u044a\u0451\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b <\/p>\n<\/li>\n<li>\n<p>\u0424\u0430\u043c\u0438\u043b\u0438\u044f<\/p>\n<\/li>\n<li>\n<p>\u0418\u043c\u044f <\/p>\n<\/li>\n<li>\n<p>\u041e\u0442\u0447\u0435\u0441\u0442\u0432\u043e <\/p>\n<\/li>\n<li>\n<p>E\u2011mail <\/p>\n<\/li>\n<li>\n<p>\u0414\u0430\u0442\u0430 \u0432\u044b\u0434\u0430\u0447\u0438<\/p>\n<\/li>\n<li>\n<p>\u0421\u0442\u0430\u0442\u0443\u0441 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f <\/p>\n<\/li>\n<li>\n<p>\u041a\u0443\u0440\u0430\u0442\u043e\u0440 \u0424\u0418\u041e<\/p>\n<\/li>\n<li>\n<p>\u041a\u0443\u0440\u0430\u0442\u043e\u0440 \u0422\u0415\u041b <\/p>\n<\/li>\n<li>\n<p>\u041a\u0443\u0440\u0430\u0442\u043e\u0440 E\u2011MAIL<\/p>\n<\/li>\n<\/ul>\n<p>\u0424\u0430\u0439\u043b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f app.py<\/p>\n<pre><code class=\"python\">import os from flask import Flask, request, render_template  from parse_table import table_courses from html2pdf import table_cert, tamplate_html from send_mail import collection_info  UPLOAD_FOLDER = 'upload\/' app = Flask(__name__)  app.config['FILE_UPLOADS'] = UPLOAD_FOLDER  @app.route('\/certificate', methods=['GET', 'POST']) def cert():     if request.method == 'POST':         # \u0428\u0430\u0431\u043b\u043e\u043d \u043f\u0438\u0441\u044c\u043c\u0430         template_email = 'templates\/sample_mail\/sample_edu_doc.html'         # \u0422\u0435\u043c\u0430 \u043f\u0438\u0441\u044c\u043c\u0430         subject_email = request.form['subject_email']         # \u0422\u0435\u043a\u0441\u0442 \u043f\u0438\u0441\u044c\u043c\u0430         text_email = request.form['text_email']         # \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u0424\u0418\u041e \u0438 \u0430\u0434\u0440\u0435\u0441\u0430\u043c\u0438         table_email = request.files['table_email']         table_email.save(os.path.join(app.config['FILE_UPLOADS'], table_email.filename))         list_email = table_cert(table_email)         # print(list_email)         cert_list = tamplate_html(list_email)         ok_list, err_list = collection_info(template_email,                                             subject_email,                                             list_email=list_email,                                             file_name=cert_list)         return render_template('list_spam.html', ok_list=ok_list, err_list=err_list)     else:         return render_template('dokuments.html')   if __name__ == '__main__':     app.run()<\/code><\/pre>\n<p>\u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 cert \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u043b\u043e\u0433\u0438\u043a\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443, \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u0438\u0441\u044c\u043c\u0430, \u0442\u0435\u043c\u0443, \u0442\u0435\u043a\u0441\u0442 \u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0434\u0430\u043b\u044c\u0448\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0444\u0430\u0439\u043b\u0435 html2pdf.py <\/p>\n<pre><code class=\"python\">import pandas as pd   list_col = ['\u041d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0435\u0440\u043e\u043f\u0440\u0438\u044f\u0442\u0438\u044f',             '\u0414\u0430\u0442\u0430 \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f',             '\u041e\u0431\u044a\u0451\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b',             '\u0424\u0430\u043c\u0438\u043b\u0438\u044f', '\u0418\u043c\u044f', '\u041e\u0442\u0447\u0435\u0441\u0442\u0432\u043e',             'E-mail',             '\u0414\u0430\u0442\u0430 \u0432\u044b\u0434\u0430\u0447\u0438',             '\u0421\u0442\u0430\u0442\u0443\u0441 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f',             '\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440',             '\u041a\u0443\u0440\u0430\u0442\u043e\u0440 \u0424\u0418\u041e','\u041a\u0443\u0440\u0430\u0442\u043e\u0440 \u0422\u0415\u041b','\u041a\u0443\u0440\u0430\u0442\u043e\u0440 E-MAIL']  def table_cert(file):     table = pd.read_excel(file)     df = pd.DataFrame(table)     table_value = df[list_col].values     # print(table_value)     cert_values = []     for i in table_value:         cert_value = {}         cert_value['event_name'] = i[0]         cert_value['event_date'] = i[1]         cert_value['program_size'] = i[2]         cert_value['surname'] = i[3]         cert_value['name'] = i[4]         cert_value['second_name'] = i[5]         cert_value['email'] = i[6]         cert_value['date_of_issue'] = i[7]         cert_value['status'] = i[8]         cert_value['reg_number'] = i[9]         cert_value['kyrator'] = i[10]         cert_value['kyrator_tel'] = i[11]         cert_value['kyrator_email'] = i[12]         cert_value['cert_file'] = f'{i[3]}{i[4]}{i[5]}_cert.pdf'         cert_values.append(cert_value)     return cert_values  import pdfkit  def html2pdf(name):     path_wkthmltopdf = b'wkhtmltopdf\\\\bin\\wkhtmltopdf.exe'     config = pdfkit.configuration(wkhtmltopdf=path_wkthmltopdf)     css = b'templates\/cert\/style_new.css'     options = {         'orientation': 'Portrait',         'page-size':'A5',         'margin-bottom': '0mm',         'margin-left': '0mm',         'margin-right': '0mm',         'margin-top': '0mm',         # 'page-width': '7.12in',     }     try:         pdfkit.from_file(f'{name}.html',                          f'{name}_cert.pdf',                          configuration=config,                          options=options, css=css)     except OSError:         pass  from jinja2 import Template import base64  def image_file_path_to_base64_string(filepath: str) -> str:     with open(filepath, 'rb') as f:         return base64.b64encode(f.read()).decode()  def tamplate_html(table):     name_cert_list = []     for cert_html in table:         context = {             'img_fon': image_file_path_to_base64_string('static\/cert\/new_fon.png'),             'img_director': image_file_path_to_base64_string('static\/cert\/\u043f\u043e\u0434\u043f\u0438\u0441\u044c.png'),             'img_pechat': image_file_path_to_base64_string('static\/cert\/\u043f\u0435\u0447\u0430\u0442\u044c.png'),              'surname': cert_html.get('surname'),             'name': cert_html.get('name'),             'second_name': cert_html.get('second_name'),             'date': cert_html.get('event_date'),             'subject':  cert_html.get('event_name'),             'time': cert_html.get('program_size'),             'number': cert_html.get('reg_number'),             'date_in': cert_html.get('date_of_issue')         }         # print(context)         html = open('templates\/cert\/index_new.html', encoding='utf-8').read()         tmp = Template(html)         out_file = tmp.render(context)         name_file = f\"{cert_html.get('surname')}{cert_html.get('name')}{cert_html.get('second_name')}\"         with open(name_file+'.html', 'w', encoding='utf-8') as f:             f.write(out_file)             f.close()         html2pdf(name_file)         name_cert_list.append(f'{name_file}_cert.pdf')     return name_cert_list <\/code><\/pre>\n<p>\u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 table_cert \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e pandas \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0438\u0437 \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439 \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0438\u0445 \u0432 \u0441\u0435\u0431\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u044f \u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430.<\/p>\n<p>\u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 html2pdf \u0437\u0430\u0434\u0430\u044e\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0431\u0443\u0434\u0443\u0449\u0435\u0433\u043e \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430: \u0440\u0430\u0437\u043c\u0435\u0440, \u043e\u0442\u0441\u0442\u0443\u043f\u044b, \u043e\u0440\u0438\u0435\u043d\u0442\u0430\u0446\u0438\u044f, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u0443\u0442\u0438 \u0434\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430(\u043e\u043d \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 pdfkit) \u0438 \u043f\u0443\u0442\u044c \u043a CSS \u0444\u0430\u0439\u043b\u0443 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0443\u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 image_file_path_to_base64_string \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0442\u043a \u0431\u0435\u0437 \u044d\u0442\u043e\u0433\u043e \u043e\u043d\u043e \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p>\u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 tamplate_html \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f html \u0448\u0430\u0431\u043b\u043e\u043d \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u0438 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 .pdf \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044f \u0432\u0441\u0435 \u044d\u0442\u043e \u0432 \u0441\u043f\u0438\u0441\u043e\u043a.<\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u0441\u043f\u0438\u0441\u043a\u0438 \u0433\u043e\u0442\u043e\u0432\u044b, \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u0432\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435  ok_list, err_list \u043e\u043d\u0438 \u043f\u043e\u0441\u043b\u0443\u0436\u0430\u0442 \u043f\u0440\u0438 \u0432\u044b\u0432\u043e\u0434\u0435 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432 \u0432\u0435\u0431 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 \u0432 \u0434\u0432\u0435 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439, \u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0435 \u0432\u044b\u0448\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0443 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e collection_info.<\/p>\n<pre><code class=\"python\">import re import os  from config import PORT, SERVER, LOGIN, PWD  import smtplib  from email.mime.application import MIMEApplication from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from email.mime.base import MIMEBase from email import encoders from email.header import Header from email.utils import formataddr  from bs4 import BeautifulSoup from jinja2 import Template   def collection_info(template, subject, list_email, **params):     ok_list, err_list = [], []     for email in list_email:         ok, error = send_email(template,                                subject,                                email.get('email'),                                first_name=email.get('name'),                                second_name=email.get('second_name'),                                cert_name=email.get('cert_file'),                                kyrator=email.get('kyrator'),                                kyrator_tel=email.get('kyrator_tel'),                                kyrator_email=email.get('kyrator_email'),                                **params)         ok_list.append(ok)         err_list.append(error)     return ok_list, err_list  def send_email(template, subject, email, **params):     server = smtplib.SMTP_SSL(SERVER, PORT)     server.login(LOGIN, PWD)     print(f'\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f email: {email}')     print(f'\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f params: {params}')     msg = MIMEMultipart()     msg['From'] = LOGIN     msg['To'] = email     msg['Subject'] = Header(subject, 'utf-8')     html = open(template, encoding='utf-8').read()     template_html = Template(html).render(subject_email=subject,                                           first_name=params.get('first_name'),                                           second_name=params.get('second_name'),                                           text_email=params.get('text_email'),                                           link_form=params.get('link_form'),                                           link_teacher=params.get('link_teacher'),                                            kyrator=params.get('kyrator'),                                           kyrator_tel=params.get('kyrator_tel'),                                           kyrator_email=params.get('kyrator_email'),                                           )     body = BeautifulSoup(template_html, 'html.parser')     msg.attach(MIMEText(body, 'html', 'utf-8'))  # \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0435\u0441\u043b\u0438 \u0432\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0435\u0441\u0442\u044c \u0434\u043e \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u044f\u0435\u043c \u043a \u043f\u0438\u0441\u044c\u043c\u0443     name_attachment = params.get('file_email')     cert_attachment = params.get('cert_name')     if name_attachment:         file_attachment = os.path.basename(name_attachment.filename)<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-374828","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/374828","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=374828"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/374828\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=374828"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=374828"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=374828"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}