r/PyScript • • Jul 17 '22

Pure Python - No HTML

It's a dream of mine to be able to code pure Python in the web browser, and I realized that PyScript allows me to do that. I've created a fork of PyScript here where I've added some Python functions that create HTML elements so you don't have to:

https://github.com/coryfitz/pydesyn

Let me know what you think! It's very much a work in progress

there's a bit more code to it than this but you get the idea (the rest is on the github page)
18 Upvotes

9 comments sorted by

View all comments

Show parent comment

1

u/manatlan Jul 18 '22

Difficult to categorize ...

The "html crafting" is the same concept as domonic. But you can (and you are encouraged) to inherit tags, to craft complex (reusable) widgets. When runned, (thru a htag runner) it instanciates an instance (of the main class) for the consumer/user (which is dedicated to that user). So "sessions" are available OOTB.

It's not dedicated to be embedded in something else. But it should be possible ... some "htag runners" are based on starlette (asgi fwk), so it's easy to declare http (or ws) endpoints in async style, to make more things with "classic web" (author oauth2, fastapi, serve statics, etc ...) .... (I don't have tested authent/author, but it should be pluggable, in a "web context")

Htag is really young ... Currently, it's a framework to make reactive apps in full python ... targetting desktop, web or android, from a single codebase.

It's really adapted to make quick app, or gui for apps ... and distribute easily.

And, it works in pyscript too ... See that (just html, no server side):

https://raw.githack.com/manatlan/htag/main/examples/pyscript_htbulma.html

it's not the goal, but it's amazing.

BTW, htag can use js statements to do more power things, in client side. But it could be easy for me, to auto "proxify" python method to be callable from htag in full python, and be full pyscript. (but it could only work in a pyscript env ... so I won't)