DmitrMakeev
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1142,7 +1142,19 @@ def se_mes_f_gc():
|
|
1142 |
|
1143 |
|
1144 |
|
1145 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1146 |
|
1147 |
|
1148 |
|
|
|
1142 |
|
1143 |
|
1144 |
|
1145 |
+
@app.route('/upload_csv', methods=['POST'])
|
1146 |
+
def upload_csv():
|
1147 |
+
if 'file' not in request.files:
|
1148 |
+
return jsonify({"error": "No file part"}), 400
|
1149 |
+
file = request.files['file']
|
1150 |
+
if file.filename == '':
|
1151 |
+
return jsonify({"error": "No selected file"}), 400
|
1152 |
+
if file and file.filename.endswith('.csv'):
|
1153 |
+
stream = io.StringIO(file.stream.read().decode("UTF8"), newline=None)
|
1154 |
+
csv_input = csv.DictReader(stream)
|
1155 |
+
data = [row for row in csv_input]
|
1156 |
+
return jsonify(data)
|
1157 |
+
return jsonify({"error": "Invalid file format"}), 400
|
1158 |
|
1159 |
|
1160 |
|