3 ms·
I usually add bottle.py[0] in my project (it's single file!) and add a simple HTML form with a submit button. When I need to show a UI, I start a server, open u
by abdusco 5y ago
I usually add bottle.py[0] in my project (it's single file!) and add a simple HTML form with a submit button. When I need to show a UI, I start a server, open up the URL and when the form is submitted, I shutdown the server and continue executing the script.
Using HTML means I can start off with plain HTML and no style (except user-agent) and keep building on it (change font, center it in the page, etc.). I can keep HTML, JS, CSS on the same page, add AlpineJS[1] if I need a reactive UI and so on.
The only thing missing is that I can't close the tab using JavaScript when it's finished, so the user (usually me) has to close it himself.
[0]: https://bottlepy.org/docs/dev/ https://bottlepy.org/docs/dev/
[1]: https://alpinejs.dev https://alpinejs.dev
- y4mi 5y ago> The only thing missing is that I can't close the tab using JavaScript when it's finished, so the user (usually me) has to close it himself. how come? doesn't window.close() work for you? save(event) { ...take the action you wanted... window.close() } <button onclick="(event) => save(event)">
- abdusco 5y agoThat only works for popup windows (ones created with `window.open()`) [0]. From MDN: > This method can only be called on windows that were opened by a script using the Window.open() method. I was unable to get `window.close()` to work on root windows, but your comment prompted me research it again. This seems to work: window.close('','_parent','') [0]: https://developer.mozilla.org/en-US/docs/Web/API/Window/close https://developer.mozilla.org/en-US/docs/Web/API/Window/clos...