from flask import Flask, request, render_template
from flask_uploads import UploadSet, configure_uploads,ALL, DATA
from werkzeug.utils import secure_filename
import os
import pandas as pd
import pygwalker as pyg
app = Flask(__name__, static_url_path='/static')
#Configuration
files = UploadSet("files", ALL)
app.config["UPLOADED_FILES_DEST"] ="static/uploads"
app.config["MAX_CONTENT_LENGTH"] = 16*1024*1024
app.config["UPLOAD_EXTENSIONS"]=[".csv"]
configure_uploads(app,files)
@app.route("/")
def index():
return render_template("index.html")
@app.route("/upload", methods=["GET", "POST"])
def upload():
if request.method == "POST" and "datafile" in request.files:
file = request.files.get("datafile")
# save to file storage
filename = secure_filename(file.filename)
path_to_saved_file = os.path.join("static/uploads",filename)
file.save(path_to_saved_file)
#processing
df = pd.read_csv(path_to_saved_file)
html_str = pyg.walk(df,return_html=True)
return render_template("index.html",html_str=html_str)
return render_template("index.html")
if __name__ == "__main__":
app.run(debug=True)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dashboard</title>
</head>
<body>
<div>
<h2>Dataverse Dashboard App</h2>
</div>
<div>
<form action="{{ url_for('upload')}}" method="POST" enctype="multipart/form-data">
<input type="file" name="datafile" id="">
<button type="submit">Submit</button>
</form>
</div>
<div>
{{ html_str | safe}}
</div>
</body>
</html>
I’ve been facing this issue for the past three days and haven’t been able to resolve it. I’ve reviewed documentation and consulted ChatGPT, but I’m still unable to fix the error. The PYGwalker UI isn’t loading in the web browser.
enter image description here
I tried to create pgywalker web app where user can upload dataset and perform EDA
New contributor
Anish Shakya is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.