Genie Discord forum

Author Avatarmi-ti
10/17/2023, 9:26:09 PM

Hi friends here, I am going to build a simple web app with genie builder, for accept csv file and do some analysis. But I found it is much difficult for me to findout how could I upload, then how and where could I acess the upload file? and there is no UI element for upload data in genie builder, is it just because the builder is not a finished tool?

Author Avatarmi-ti
10/17/2023, 9:26:55 PM

Changed the channel name: how to upload a csv file with in genie builder

Author AvatarPere
10/18/2023, 2:32:05 PM

At the moment, the file uploader component is not supported in Genie Builder. You'd have to include it in the HTML with something like

<%             uploader(label="Upload Dataset", accept=".csv", multiple=true, method="POST", url="http://localhost:8000/", field__name="csv_file", @on("uploaded", :uploaded))
Author AvatarPere
10/18/2023, 2:33:07 PM

This component requires a little setup to get it working. We have a tutorial and a repo with an example

Author Avatarmi-ti
10/18/2023, 6:24:04 PM

Thank you very much, it is a great resource for learning.

Author Avatarmi-ti
10/18/2023, 6:45:55 PM

I am still a little confused. I could add the file uploader component in the html page, but I cannot upload the file to server.

in the csvuploader tutorial, there is some route code to handle the post event:

route("/", method=POST) do
# some code...
upfiles = readdir(FILE_PATH)
# some other code...
@page("/", "ui.jl")

but in my code, since I use the genie builder to make the UI page, I have below code in app.jl:

@app begin
# my logit code here
  @onchange xxx begin
  # ...

@page("/", "app.jl.html")

and my html page is something like:

<%             uploader(label="Upload Dataset", accept=".csv", multiple=true, method="POST", url="http://localhost:9101/upload", field__name="csv_file", @on("uploaded", :uploaded))

so how could I add a route rule to tell the app how to handle the upload files?

Author Avatarmi-ti
10/22/2023, 7:50:48 PM

finally I solved this, and just give a record here:

  1. insert. the uploader html. code into app.jl.html, include them with "<% %>"
  2. add the configure within the app,jl, before "@app begin"
  3. this is the key step!!! restart the whole app, the genie donot autoreload it!!! even its log shows it is autoreload on every save step!!!