Files
WebServer/app.py

85 lines
3.5 KiB
Python
Raw Normal View History

2025-08-15 14:58:11 +08:00
from waitress import serve
from flask import Flask, render_template, request, redirect, url_for, jsonify
from datetime import datetime
app = Flask(__name__)
# 模拟数据库数据
company_info = {
"name": "安吉捌壹智能科技有限公司",
"slogan": "智能科技,创造未来",
"about": "捌壹智能科技有限公司成立于2020年是一家专注于人工智能、大数据分析和数字化转型的高科技企业。我们致力于为客户提供创新的技术解决方案助力企业实现数字化升级。",
"services": [
{
"name": "人工智能解决方案",
"description": "为企业提供定制化AI解决方案包括机器学习、计算机视觉和自然语言处理等。"
},
{
"name": "大数据分析",
"description": "通过先进的数据分析技术,帮助企业挖掘数据价值,优化决策过程。"
},
{
"name": "数字化转型咨询",
"description": "为企业提供全面的数字化转型战略规划和技术实施支持。"
}
],
"contact": {
"address": "中国北京市海淀区科技园路88号",
"phone": "+86 10 8888 8888",
"email": "info@baize-digital.com"
}
}
@app.route('/')
def index():
return render_template('index.html', company=company_info)
@app.route('/about')
def about():
return render_template('about.html', company=company_info)
@app.route('/services')
def services():
return render_template('services.html', company=company_info)
# @app.route('/contact', methods=['GET', 'POST'])
# def contact():
# if request.method == 'POST':
# # 这里可以添加处理联系表单的逻辑
# name = request.form.get('name')
# email = request.form.get('email')
# message = request.form.get('message')
# # 通常这里会发送邮件或保存到数据库
# print(f"收到来自 {name}({email}) 的消息: {message}")
# return redirect(url_for('contact', success=True))
# return render_template('contact.html', company=company_info, success=request.args.get('success'))
# 收到小程序,发送过来的数据,暂时在这里进行存储
@app.route('/contact', methods=['GET', 'POST'])
def contact():
if request.method == 'POST':
form_data = request.get_json() # 直接解析 JSON
# customerName = form_data.get('customerName', '')
# projectSource = form_data.get('projectSource', '')
# projectLeader = form_data.get('projectLeader', '')
# clientdemand = form_data.get('clientdemand', '')
# handovertasks = form_data.get('handovertasks', '')
# remarks = form_data.get('remarks', '')
# # 暂时保存在 txt 文件中
# # 生成文件名
# filename = "D:/ProjectManagementSystem/data/" + datetime.now().strftime("%Y%m%d_") + customerName+ "_" + projectLeader+ ".txt"
# # 要保存的内容
# content = f"文件生成时间:{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n\n" + customerName + "\n\n" + projectSource+ "\n\n" + projectLeader+ "\n\n" + clientdemand+ "\n\n" + handovertasks+ "\n\n" + remarks
# # 写入文件
# with open(filename, "w", encoding="utf-8") as file:
# file.write(content)
return jsonify({"status": "success", "message": "提交成功"})
return render_template('contact.html', company=company_info, success=request.args.get('success'))
if __name__ == '__main__':
serve(app, host='0.0.0.0', port=777)