I'm pretty new to Python and not sure, where to start searching. For a small project I'm trying to figure out if one can manipulate CSS code via python, so that dynamic changes are visible in a browser without refreshing the page? Say you want to change the background of some DIV from green to red depending on a recurring python expression/events after the page has been loaded, like a status indicator that changes over time.
Update: The project is a simple network scanner. As pings have to be handled asynchronous, I have to find a way to update the online status of a host in a table after the page has been loaded. It's a HTML page hosted on my Mac, which I open in a tool, which displays it as a dektop wallpaper.
Short answer? Sort of.
What you see in a browser is some application (Chrome, Firefox, Safari), parsing an html file that may contain various text, tags, js, css, etc...and making the determination of how to render that content.  In order for the content to update/change, the html must either re-load or have some javascript  running that directly changes the Document Object Model (DOM). But currently,  there is no mechanism for running python inside of a web page.
Now, that being said, what you could do is have some Javascript that listened or polled a server written in Python that emitted content/messages/events that your JS framework (in the webpage) responded to and would make the appropriate changes in your DOM. It's not uncommon and that's how a lot of web pages do what they do: Some 'Backend', could be Python or C# or even JS, that responds to requests from a 'Frontend' e.g. your webpage or browser, and sends content, sometimes as JSON instead of HTML.
Is it possible to do live css changes on a HTML page via python?