HackerTrans
TopNewTrendsCommentsPastAskShowJobs

Wang0618

no profile record

Submissions

Show HN: GoRay – Ray Core for Golang

github.com
3 points·by Wang0618·7 ay önce·0 comments

Show HN: PyWebIO – Write interactive web app in script way

github.com
200 points·by Wang0618·5 yıl önce·37 comments

comments

Wang0618
·4 yıl önce·discuss
Here is a more relative one: https://web.archive.org/web/20000307060602/http://geocities....

Once, I collected some ascii art and made a online gallery (https://ascii-art.pywebio.online/#0_joan_stark.cat_love), "cats on a fence " is one of them
Wang0618
·5 yıl önce·discuss
Awesome work! I also developed a similar project called PyWebIO (https://github.com/pywebio/PyWebIO) last year. It provides less control to HTML element but provides a straightforward way to make input and output. Hope we can learn from each other's project.
Wang0618
·5 yıl önce·discuss
You can place a password validation input at the beginning of the code and return directly if the validation does not pass. PyWebIO ensures that only users who have passed the validation can continue with the rest of the code.
Wang0618
·5 yıl önce·discuss
Both http and websocket protocol can be used to implement server-browser communication in PyWebIO. The websocket is default, and you can use `pywebio.platform.tornado_http.start_server()` or `pywebio.platform.path_deploy_http()` to use http polling to communicate.
Wang0618
·5 yıl önce·discuss
PyWebIO won't re-execute the whole script. In pywebio, if the code executes to the end, the user session will also be closed. You can use `while` loop in your code to continuously receive user input in PyWebIO app.

PyWebIO now support defining inputs based on other ones, but I haven't written this feature into the documentation. Until then, you can solve this problem by splitting inputs with dependencies into multiple forms. (you can use first form to get company and then use another form to get employee)
Wang0618
·5 yıl önce·discuss
You can check this section first: https://pywebio.readthedocs.io/en/latest/guide.html#server-m...

More details about deployment will be added to the documentation later.
Wang0618
·5 yıl önce·discuss
PyWebIO is more lightweight and supports coroutine and web framework integration.

Although PyWebIO is indeed a bit crude, the usage scenarios of PyWebIO and streamlit don't exactly overlap.
Wang0618
·5 yıl önce·discuss
Streamlit uses a responsive way to get input and doesn't rely on callbacks at all. Every time a user interacts with a widget, your script is re-executed and the output value of that widget is set to the new value during that run. It's amazing but also a little hard to understand.

In contrast, the way of writing PyWebIO app is more like writing a terminal program, except that the terminal here becomes a browser. The output functions will output content to user in real time, and the input functions will block until the user submit the input form.
Wang0618
·5 yıl önce·discuss
PyWebIO is a Python library which provides a series of imperative functions to obtain user input and output on the browser. The input function of PyWebIO is blocking, and the output function will output content to user in real time.

You can use PyWebIO to build simple web applications or browser-based GUI applications without the need to have knowledge of HTML and JS.

The way of writing PyWebIO applications is more like writing a terminal program. You can think of the browser as a rich text terminal while writing PyWebIO app. If you have a terminal script, you only need to replace the input and output functions with PyWebIO's functions to turn your terminal script to a web application.

Features:

- Support click events, layout and output updates.

- Support integration into existing web project, currently supports Flask, Django, Tornado, aiohttp framework. - Support for asyncio and coroutine.

- Compatible with data visualization libraries, e.g., plotly, bokeh, pyecharts.

Links:

- Demos: http://pywebio-demos.demo.wangweimin.site/

- Documents: https://pywebio.readthedocs.io/en/latest/

PS: I am not a native speaker of English, so the documents may be a bit obscure. If you have any questions, please feel free to discuss on https://github.com/wang0618/PyWebIO/discussions