私はユーザーに読み込み画面を提供する方法を理解しようとしています。 ユーザーがボタンをクリックする(送信しない)と、サーバーと通信してオンザフライでPDFを生成します。この処理には約3.2秒かかり、その間に読み込み画面を提供したい。私が直面している問題は、画面を読み込むための利用可能なソリューションの多くは、読み込み用GIFをオフにするためにページをリロードする必要があるということです(この場合は「投稿」)。 私のPDFビューのダウンロード機能は以下の通りです。 PDFダウンロードボタンをクリックすると、読み込み画面が表示され、PDFファイルがダウンロードされる直前に読み込み画面が消えるという解決策を探しています。PDFを生成中のFlask Loading Screen
@post_user_blueprint.route('/download_pdf/<string:test_id>/<string:created_on>/<string:test_type>', methods=['GET', 'POST'])
@login_required
@human_readable_log('Downloaded a PDF')
def download(test_id, created_on, test_type):
from app.views.utility import PDFSystem
pdf_system = PDFSystem(test_id=test_id, created_on=created_on, test_type=test_type)
pdf = pdf_system.create_pdf('dynamic_pdf_template.html')
_filename = test_type +'_'+ test_id
response = make_response(pdf)
response.headers['Content-Type'] = 'application/pdf'
response.headers['Content-Disposition'] = 'attachment; filename=' + _filename
return response