[HN Gopher] Show HN: PyWebIO - Write interactive web app in scri...
       ___________________________________________________________________
        
       Show HN: PyWebIO - Write interactive web app in script way
        
       Author : Wang0618
       Score  : 158 points
       Date   : 2021-03-23 13:00 UTC (10 hours ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | TruthWillHurt wrote:
       | Did I just spend 100k building a React portal for nothing?? :D
        
         | erichurkman wrote:
         | You built it so you can refactor it when React `${v+1}` comes
         | out, or when Webpack `${v+.1}` breaks your build.
         | 
         | I may or may not have dropped an /s somewhere on the floor.
        
       | [deleted]
        
       | bernardv wrote:
       | This is great. Does it rely on web sockets?
        
         | crazypython wrote:
         | It seems to stream the HTML over the original HTTP socket- web
         | browsers can render incomplete streams of HTML.
        
         | lovasoa wrote:
         | Looking at it from the web inspector, yes, it's entirely over
         | websockets, sending json messages :                   {"event":
         | "input_event","task_id":"main-140213579376912","data":{"event_n
         | ame":"blur","name":"weight","value":"21"}}         {"command":
         | "output", "spec": {"type": "markdown", "content": "Your BMI:
         | `1458.3`, Category: `Severely obese`", "sanitize": true,
         | "scope": "#pywebio-scope-ROOT", "position": -1}, "task_id":
         | "main-140213579376912"}
        
       | pytlicek wrote:
       | Thanks for sharing. This is really awesome!
        
       | bbaumgar wrote:
       | Between idom[0], streamlit[1], anvil[2], and PyWebIO this space
       | is moving quickly.
       | 
       | While it's a little rough around the edges, idom has worked great
       | for us. I look forward to trying out PyWebIO at some point - it
       | targets a different but valid use case.
       | 
       | [0] idom-docs.herokuapp.com/ [1] https://streamlit.io/ [2]
       | https://anvil.works/
        
         | Aliabid94 wrote:
         | Gradio is another one optimized for testing functions / ML
         | models. https://gradio.app
        
         | imhoguy wrote:
         | That is cool stuff!
         | 
         | Does anyone know something like these in Ruby ecosystem? For
         | heavily invested in RoR apps such rapid prototyping from
         | `irb`/`pry` would be a day saver.
        
       | raghavkhanna wrote:
       | I really like the concept, thanks for sharing!
        
       | JPKab wrote:
       | How is this different from streamlit?
       | 
       | Curious.
        
         | Wang0618 wrote:
         | 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.
        
           | JPKab wrote:
           | Excellent work, and thank you for sharing!
           | 
           | I see some immediate applications for this at my job. Much
           | appreciation!
        
           | yamrzou wrote:
           | So, PyWebIO doesn't re-execute the whole script like
           | Streamlit does? I use streamlit, and that's one of its pain
           | points. If the script is complicated, re-execution becomes
           | slow.
           | 
           | Also does PyWebIO support defining inputs based on other
           | ones? For example, to have a hierarchy of dropdowns (select
           | company --> based on that selection, select employee -->
           | etc).
        
         | manojlds wrote:
         | Not finding a reason to use this over Streamlit which is pretty
         | polished and has good layout, pandas df support and other nice
         | bells and whistles.
         | 
         | Edit: actually did. Running apps from a directory was something
         | I was looking for and there was only a third party effort for
         | Streamlit for this -
         | https://pywebio.readthedocs.io/en/latest/platform.html#direc...
        
           | michaelmior wrote:
           | What do you mean by "running apps from a directory?" Do you
           | mean having multiple streamlit apps in a folder and being
           | able to access all of them using a single server?
        
           | Wang0618 wrote:
           | 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.
        
       | hirot890p wrote:
       | Looks awesome! Please add a step by step guide to deploy it to a
       | web server.
        
       | Wang0618 wrote:
       | 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
        
         | RandomWorker wrote:
         | This is awesome! I'm going to use this to make a couple of
         | applications! I've been looking for something to quickly make
         | something easy for my clients. I'll probably put these behind a
         | user-pass, but are there any issues that might arise security
         | wise?
        
         | offtop5 wrote:
         | Looks great, the docs look fine to me, but I would love
         | instructions on how to deploy these applications.
         | 
         | I imagine this will let Python devs create small web front ends
         | very easily .
        
           | raghavkhanna wrote:
           | perhaps this link might help https://pywebio.readthedocs.io/e
           | n/latest/guide.html#server-m...
        
         | [deleted]
        
         | hultner wrote:
         | Looks really cool, I love how simple it is.
        
         | jimsparkman wrote:
         | Fantastic work! This looks like an arguably better/more
         | generalized version of something like Streamlit.
         | 
         | Great concept for building rapid applications.
        
       | vsskanth wrote:
       | Examples and demo gifs look simple and easy to understand.
        
       | OttPeterR wrote:
       | As someone who has only done back end for years and is lazy and
       | don't want to learn front end stuff, this is an inviting way to
       | break into that world for me.
        
       | floatingleaf wrote:
       | https://github.com/codevin/script-manager
       | 
       | The idea here is to standardize widgets and use them from
       | scripts. For now, it emulates whiptail command line which
       | provides text widgets.
        
       | 55555 wrote:
       | I would love to use this. How do I deploy it to the web easily
       | and cheaply?
        
       | clipradiowallet wrote:
       | This was easy to install and get started with. I have a [ton] of
       | one-off python scripts for various work-related purposes we all
       | use. Things like PyWebIO can make them accessible to management
       | types, who aren't going to read the usage or spend time
       | understanding how to call them via CLI properly.
       | 
       | Thanks to the author!
        
       ___________________________________________________________________
       (page generated 2021-03-23 23:01 UTC)