Follow

Okay, I've absolutely had enough of the ridiculous JS ecosystem, except for where I absolutely need it in the browser for something that can't otherwise be done.

I want to learn how to do all the same stuff with Python because it looks like a better ecosystem. I'm a complete noob so I'm going to just accept looking silly and ask noob questions.

Could I make a little executable with python that would simply spin up a localhost and open a bundled static site in the default browser?

@freedcreative i don't have experience with it, but yes I'm pretty sure there's python libraries for this just like there's PHP.

I similarly regret (modern) JavaScript. So much can be done serverside that has been pushed to the client. So much doesn't need to be done at all.

@68km @ItsTheManOnTheMoon @dmoonfire @alcinnz @morgan Absolute legends, thank you so much!

For context, I'm working on a browser game but with all vanilla code. I want people to be able to download & run a copy like they're used to. But I don't see why a downloadable web game, or any app, needs to bundle a browser when everybody already has one.

So the idea is you run the game and it just opens in your preferred browser.

@freedcreative @68km @ItsTheManOnTheMoon @alcinnz @morgan They are lots of options that don't require shipping electron. Every language sucks until you grok it then it makes perfect sense, but you *will* regret your choice no matter what you pick. 😁

But every language had the ability to say "open default browser here" and client/server is still a thing.

So I say, find your language of choice and go on an adventure.

@freedcreative Yes (one example is stackoverflow.com/a/51295415). I think that same problem is why I've gravitated more toward C# and WASM because it does everything, I like it's packaging ecosystem better, and doesn't need Javascript at all.

Though, DeVault's recent rant about Python seem apropos at the moment. drewdevault.com/2021/11/16/Pyt

(Technically, his NPM rant also drewdevault.com/2021/11/16/Cas )

@freedcreative For something bare bones there's the SimpleHTTPServer module builtin (which as @ItsTheManOnTheMoon mentioned can also be invoked on the commandline to serve as a static file server, exactly what you requested), though there's several modules installable from Pypi which are more convenient for building serverside-dynamic sites.

Popular ones include Flask, CherryPy, and the full-featured Django.

@freedcreative indeed you can! Take a look at flask ( flask.palletsprojects.com/en/2 ), which is a cute but very powerful "microframework" which can serve static websites and also templates written with jinja so you can serve dynamic content as well. packaging all that is easy in python, but if you really want an executable, you can compile python code with cython and there are tools to make executables from that (py2exe for windows but I never used that)

@freedcreative you're about to find out that:
a) pip is worst than yarn
b) the python ecosystem and community is heavily skewed for AI training
c) python3 is fighting against python2 for its dear life
d) it's very VERY slow

@freedcreative that being said, it's a fun language with interesting quirks, it's well worth knowing, if only to bring you toward a better place and away from javascript :)

I had to learn it, and I'm glad I did, and you should too.

@freedcreative there's a million languages out there, it doesn't end at python. Keep pulling that thread :)

@neauoire :) Thanks

Talon Voice configs are done in python, so maybe getting more comfy with the language will let me use that to access more languages and build tools, even if I never get my hands back properly.

Being stuck on tablets is a frickin nightmare.

@freedcreative python is a very common language for IoT things, so there might be something there :)

@neauoire @freedcreative why buy in to any ecosystem? Live in your own! (with good friends)

@deianeira I just don't have the bandwidth to write everything from scratch myself. I'd like to move in that direction as much as possible, but for the foreseeable future I'm gonna need some existing tools to lean on.

@freedcreative @deianeira Sorry to butt into others conversation here, but what about Lua? Small, pretty standardized for a while now, fast, moderate sized ecosystem. works in software and hardware spaces

@exquisitecorp Not at all, I appreciate any help I can get!

I have been wondering about Lua. Atm I have to use an Android tablet for coding, for accessibility purposes, so I've been looking for things I have availability via Termux. It doesn't really deal with anything graphical, which is why I've been looking at the browser to handle said graphics.

But I wonder if there's a way I could access Lua anyhow.

@freedcreative @exquisitecorp Termux means that you can use SDL2, which basically opens the door ALL THINGS graphical :)

@neauoire I spotted that when I was looking into trying to use pygame! I know almost nothing about it, except that it's a major component of uxn.

I would definitely like to learn more. I did start reading, but I think it's going to take a while though as it's all very new. I got as far as installing it and exploring frameworks and engines that use it.

My coding experience is basically all in the context of web and game engines so I have a lot in front of me.

@freedcreative you're at the right place if you need help with any of those :merveilles:

@exquisitecorp Holy shit LÖVE has an Android APK they say you can use for dev! This might be exactly what I need!

@exquisitecorp Holy balls it totally works!! 🥳 🍾

I can use an actual game engine! Thank you!!!

@freedcreative @neauoire Keep tugging at the python string, can do way worse than python and it has a lot of good stuff going for it.

If you can be one thing you should be curious! Very little cost to learning new languages/environments these days. Just time.

@freedcreative If the site is completely static, you can just open local files directly in a browser. No http server needed.

If you're dealing with a desktop OS, that is. Mobile browsers are a whole 'nother can of worms.

@asquare I'll probably be using localstorage for saving game progress, so I need http for that to be reliable afaik.

Simple, lightweight, and magic-free static site/blog generator for Python coders | PythonRepo



sunainapai/makesite, makesite.py Take full control of your static website/blog generation by writing your own simple, lightweight, and magic-free static site generator in

@zap This looks very useful, and straight forward enough to learn from too. Thanks!

@freedcreative If you end up sticking with JavaScript a sorta stupid idea that comes to mind is your executable being a simple bash script that calls xdg-open on your index.html file.

@freedcreative AFAIK opening the OS default browser at a specific link is a one liner in python

@freedcreative looks like you have lots of suggestions but I'll add a simple option in case it's useful.

In my .bashrc / .zshrc I have this alias

`alias serve="ip address && python -m http.server 1312" `

I just type serve in the dir I need and then I can test stuff on different devices quickly. I also use it to lazily transfer files to my phone or my partner wants to watch a film I torrented on my laptop on theirs.

Sign in to participate in the conversation
Merveilles

Revel in the marvels of the universe. We are a collective of forward-thinking individuals who strive to better ourselves and our surroundings through constant creation. We express ourselves through music, art, games, and writing. We also put great value in play. A warm welcome to any like-minded people who feel these ideals resonate with them.