is writing a simple web app in flask.
the function you want to achieve is:
- upload an excel file
- Clean up the data with pandas
- the resulting dataframe is previewed with a table at the front end After the
- preview is correct, upload it to the database
now it is stuck in 3. Front-end preview here. When you click the Preview button, you will always jump to the new path / extract
and return the data in json format. The younger sister checked a lot of materials, jquery
, jquery.datatables
, bootstrap-table
, all used it again. That is, an error will be reported in get / extract 400
. Please give us some advice!
views.py
@app.route("/extract", methods=["GET", "POST"])
def extract_excel():
file = request.files["file"]
filename = file.filename
path = os.path.join(os.getcwd(), filename)
file.save(path)
-sharp excel df,
df_json = df.to_json(orient="records", force_ascii=False)
return df_json
index.html
<div>
<form action="/extract" method="post" enctype="multipart/form-data">
<input type="file" name="file"></input>
<input type="text" name="upload_date" placeholder="2018-01-01"></input>
<button type="submit" id="showtable"></button>
</form>
</div>
ask for a front-end method no matter what plug-in is used. After clicking the "Preview" button, ajax can display dataframe on the current page. Thank you
.