Skip to content

Commit 7bc82fd

Browse files
committed
fix admin upload
1 parent 066a320 commit 7bc82fd

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

src/client/src/pages/Admin.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class Admin extends Component {
5555
await this.handleGetFileList();
5656
await this.handleGetStatistics();
5757

58-
this.setState({isLoading: false})
58+
await this.setState({isLoading: false})
5959
}
6060

6161
componentDidMount() {
@@ -78,14 +78,13 @@ class Admin extends Component {
7878
formData.append('file', element, element.name)
7979
})
8080

81-
await fetch("/api/file", {method: 'POST', body: formData,
81+
await fetch("/api/file", {
82+
method: 'POST',
83+
body: formData,
8284
headers: {
83-
'Content-Type': 'application/json',
8485
'Authorization': 'Bearer ' + this.props.access_token
8586
}})
8687

87-
88-
8988
await this.handleGetFileList();
9089

9190
await this.setState({
@@ -105,7 +104,6 @@ class Admin extends Component {
105104
{
106105
method: 'GET',
107106
headers: {
108-
'Content-Type': 'application/json',
109107
'Authorization': 'Bearer ' + this.props.access_token
110108
}
111109
});
@@ -118,7 +116,6 @@ class Admin extends Component {
118116
{
119117
method: 'GET',
120118
headers: {
121-
'Content-Type': 'application/json',
122119
'Authorization': 'Bearer ' + this.props.access_token
123120
}
124121
});
@@ -139,7 +136,6 @@ class Admin extends Component {
139136
{
140137
method: 'GET',
141138
headers: {
142-
'Content-Type': 'application/json',
143139
'Authorization': 'Bearer ' + this.props.access_token
144140
}
145141
});

src/server/api/admin_api.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from api.api import admin_api
2-
import shutil
32
import os
43
from datetime import datetime
54
import json
@@ -16,23 +15,19 @@
1615
from config import (
1716
RAW_DATA_PATH,
1817
CURRENT_SOURCE_FILES_PATH,
19-
LOGS_PATH,
2018
)
2119

2220
ALLOWED_EXTENSIONS = {"csv", "xlsx"}
2321

22+
2423
def __allowed_file(filename):
2524
return "." in filename and filename.rsplit(".", 1)[1].lower() in ALLOWED_EXTENSIONS
2625

2726

28-
2927
# file upload tutorial
3028
@admin_api.route("/api/file", methods=["POST"])
3129
@jwt_ops.admin_required
32-
def uploadCSV():
33-
if "file" not in request.files:
34-
return redirect(request.url)
35-
30+
def upload_csv():
3631
for file in request.files.getlist("file"):
3732
if __allowed_file(file.filename):
3833
try:

0 commit comments

Comments
 (0)