我们提供融合门户系统招投标所需全套资料,包括融合系统介绍PPT、融合门户系统产品解决方案、
融合门户系统产品技术参数,以及对应的标书参考文件,详请联系客服。
from flask import Flask, request, jsonify
import pandas as pd
from pptx import Presentation
app = Flask(__name__)
@app.route('/generate', methods=['POST'])
def generate_report():
data = request.json
student_id = data['student_id']
# 数据提取与处理
df = pd.read_sql(f"SELECT * FROM students WHERE id={student_id}", db_connection)
template_path = "templates/report_template.pptx"
prs = Presentation(template_path)
# 填充数据至幻灯片
for slide in prs.slides:
for shape in slide.shapes:
if shape.has_text_frame:
text_frame = shape.text_frame
for paragraph in text_frame.paragraphs:
for run in paragraph.runs:
if "${student_name}" in run.text:
run.text = run.text.replace("${student_name}", df.loc[0, 'name'])
output_path = f"output/{student_id}_report.pptx"
prs.save(output_path)
return jsonify({"status": "success", "file": output_path})
]]>