question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Any means to download the file?

See original GitHub issue

I’d like to create a button which, when clicked, causes a file to be downloaded in the browser. To my understanding, in regular HTML this is handled by href attribute.

I tried: ui.button('Download configuration file').classes('my-2 mx-4').props('href=https://quasar.dev') which, according to https://quasar.dev/vue-components/button#example--links, I thought, should cause the browser to issue GET request to go to quasar.dev website. But there’s no reaction after click.

Or should it be handled with ui.add_route for serving the file and on_click=lambda: ui.open(route_url) button argument?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
falkoschindlercommented, Jun 8, 2022

To my understanding, in regular HTML this is handled by href attribute.

Yes, the href attribute points to the location where the resource can be accessed. The server, however, needs to provide the file at this location. Since NiceGUI implements frontend and backend, you need to take care of both.

Using ui.get is totally fine. You could even leave out the request argument. Since version 0.7.28 you can also use ui.add_static_files('/some/route', 'path/to/some/folder'). Then you can access every file in this folder via e.g. `/some/route/file.json’.

Wrapping a button inside a link seems a little weird. Combining a button with ui.open should work:

ui.button('Download', on_click=lambda e: ui.open('/some/route/file.json', e.socket))

Note that without providing the socket, every browser connected to the app would open the file, not only the one that triggered the click event.

0reactions
me21commented, Jun 9, 2022

So it’s not only me? I thought my Firefox extensions could play tricks on me. Oh well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Download a file - Android - Google Chrome Help
Go to the web page where you want to download a file. Touch and hold what you want to download, then tap Download...
Read more >
What is downloading? - TechTarget
Downloading is the transmission of a file or data from one computer to another over a network, usually from a larger server to...
Read more >
Download files from the web - Microsoft Support
Learn how to download files from the web, change your default download location, and find files you've downloaded on your PC using Internet...
Read more >
Basic Computer Skills: Downloading and Uploading
Downloading means receiving data or a file from the Internet on your computer. Uploading means sending data or a file from your computer...
Read more >
Download items from the web using Safari on Mac
In Safari on your Mac, download music, a PDF, software, and other items. Also see what you downloaded previously.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found