-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
32 lines (31 loc) · 1.07 KB
/
Copy pathapp.py
File metadata and controls
32 lines (31 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from flask import Flask, render_template, request, jsonify
import pandas as pd
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def sign(): # put application's code here
return render_template('sign.html')
@app.route('/index', methods=['GET', 'POST'])
def index(): # put application's code here
if request.method == 'POST':
return render_template('top.html')
return render_template('index.html')
@app.route('/data')
def data():
return render_template('csvdata.html')
@app.route('/3D')
def _3D():
return render_template('3D.html')
@app.route('/csvdata', methods=['GET', 'POST'])
def get_csv_data():
# 读取 CSV 文件
try:
csv_file = r'/Users/fang/Downloads/flask/predictions.csv'# 替换为 CSV 文件路径
df = pd.read_csv(csv_file)
csv_data = df.to_dict(orient='records')
return jsonify(csv_data)
except FileNotFoundError:
return jsonify({"error": "File not found"}), 404
except Exception as e:
return jsonify({"error": str(e)}), 500
if __name__ == '__main__':
app.run(debug=True)