Skip to content

Commit

Permalink
add endpoint for uploading spreadsheet and getting back response with…
Browse files Browse the repository at this point in the history
… data file path and sheet names
  • Loading branch information
devowit committed Sep 29, 2021
1 parent 3191951 commit 4b98254
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions backend/causx_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,23 @@ def causx_upload_project():
response["filepath"]=filemap["data"]
return response, 200

@app.route('/api/causx/upload/spreadsheet', methods=['POST'])
@json_response
def causx_upload_spreadsheet():
project = get_project()
in_file=causx_get_file([".csv", ".xlsx"])

folder = Path(project.directory)
shorter_name = Path(in_file.filename).name
filename = secure_filename(shorter_name)
file_path = folder/filename
in_file.save(str(file_path))

file_path = project.add_data_file(file_path)
response =dict()
response["data_file"]= file_path
response["sheet_names"]=project.data_files[file_path]["val_arr"]
return response, 200



Expand Down

0 comments on commit 4b98254

Please sign in to comment.