Is it possible to write Python
scripts in HTML code similarly as you write PHP between <?php ... ?>
tags?
I'd like to achieve that my Python
application will run in the browser.
thank you for help
PyScript is an open source web framework that allows you to create frontend web applications using Python. With PyScript, you can either embed Python code in HTML, or link to a Python file and the code will execute in the browser — without running Python in the backend.
Yes, but not directly; you can set the onclick handler to invoke a JavaScript function that will construct an XMLHttpRequest object and send a request to a page on your server. That page on your server can, in turn, be implemented using Python and do whatever it would need to do.
Python indentation requirements don't go well with mixing HTML and Python code. Therefore, the most prominent method (which is a framework called Django), uses a template engine so that the Python is never in direct contact with the HTML code.
It will be similar to PHP and not javascript, as it will run on the server-side.
There is also mod_python for Apache, but I would strongly recommend using Django, which also runs on an Apache server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With