Showing
1 changed file
with
27 additions
and
2 deletions
| 1 | -from flask import render_template | 1 | +from flask import Flask, render_template, request |
| 2 | + | ||
| 3 | +import json | ||
| 4 | +app = Flask(__name__) | ||
| 5 | +app.config['UPLOAD_FOLDER'] = 'data/' # 上传文件的保存目录 | ||
| 6 | +ALLOWED_EXTENSIONS = {'csv'} # 允许的文件扩展名 | ||
| 7 | +processing_status = {} # 全局字典用于存储处理状态和统计信息 | ||
| 2 | 8 | ||
| 3 | @app.route('/') | 9 | @app.route('/') |
| 4 | def upload_form(): | 10 | def upload_form(): |
| 5 | """显示文件上传表单""" | 11 | """显示文件上传表单""" |
| 6 | - return render_template('main.html') | ||
| 12 | + return render_template('main.html') | ||
| 13 | + | ||
| 14 | +@app.route('/waiting/<filename>') | ||
| 15 | +def waiting_page(filename): | ||
| 16 | + """显示等待页面,并传递文件名""" | ||
| 17 | + return render_template('waiting.html', filename=filename) | ||
| 18 | + | ||
| 19 | +@app.route('/upload-success') | ||
| 20 | +def upload_success(): | ||
| 21 | + """文件处理成功页面""" | ||
| 22 | + filename = request.args.get('filename') | ||
| 23 | + stats = processing_status.get(filename, {}).get('stats', {}) | ||
| 24 | + return render_template('success.html', stats=stats) | ||
| 25 | + | ||
| 26 | +@app.route('/upload-failure') | ||
| 27 | +def upload_failure(): | ||
| 28 | + """文件处理失败页面""" | ||
| 29 | + filename = request.args.get('filename') | ||
| 30 | + stats = processing_status.get(filename, {}).get('stats', {}) | ||
| 31 | + return render_template('failure.html', stats=stats) |
-
Please register or login to post a comment