pyscript

Why doesn't this PyScript code work as it should?

Why doesn't this PyScript code work as it should? Question: I was creating a calculator PyScript program for a school project when the script stopped working as it should. I had to use the alpha PyScript to even make a working calculator for some reason, if that matters. My code: <!DOCTYPE html> <html> <head> <meta …

Total answers: 1

How to use my own python packages/modules with PyScript?

How to use my own python packages/modules with PyScript? Question: Question I came across pyscript hoping to use it to document python code with mkdocs. I have looked into importing my own module. Individual files work. How do I import my own module using pyscript instead? Requirements for running the example: python package numpy ($ …

Total answers: 2

How to link to python file inside html code

How to link to python file inside html code Question: So I have created a game (of sorts) in python that I want to embed into an html webpage so I can add UI features. I have used the tags to do this but I am having issues with importing packages and also it clutters …

Total answers: 1

PyScript: is it possible to execute an uploaded Python script?

PyScript: is it possible to execute an uploaded Python script? Question: Is it possible to have a user upload an arbitrary Python script (that uses built-ins only, no external packages) and then execute it using PyScript? Asked By: SultanOrazbayev || Source Answers: You can use an HTML <input> element to upload the file, and use …

Total answers: 1

how to get active REPL block in PyScript and copy whatever code written in it?

how to get active REPL block in PyScript and copy whatever code written in it? Question: I have multiple code blocks in pyscript repl which were created dynamically on button click. I want to know which code block is active. I know library adds cm-activeLine class when line is active but that changes when I …

Total answers: 1

What is the basic difference between Brython and PyScript?

What is the basic difference between Brython and PyScript? Question: I was trying to understand the difference between PyScript and Brython. So I read the following post: PyScript vs. Brython — What’s the Difference? and didn’t understand anything apart from the following line: Brython converts Python code into native JavaScript, while PyScript is native Python …

Total answers: 2

Call apis on web with py-script

Call apis on web with py-script Question: I try to call an API with http.client th error says that the ‘http.client’ has no attribute ‘HTTPSConnection’ The code is: import http.client conn = http.client.HTTPSConnection("www.banxico.org.mx") payload = ” headers = {} conn.request("GET", "/SieAPIRest/service/v1/series/SP68257/datos/2022-11-11/2022-11-11?token=04021aac739b77e232d9670147936836e9e9fc31e08bde26665c0f013df94471", payload, headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) The code work well on …

Total answers: 2

Calling py-script function from button-click with "pys-onClick=…" doesn't work?

Calling py-script function from button-click with "pys-onClick=…" doesn't work? Question: I’m relatively new to PyScript and would like to run a function when a button is clicked. However, no matter what code I try, it doesn’t seem to work. The button is clickable but doesn’t appear to do anything. When I call the function manually …

Total answers: 1

How to effectively translate Javascript fetch functions into Pyscript?

How to effectively translate Javascript fetch functions into Pyscript? Question: So recently I’ve been dealing with making a website using Pyscript. But i cannot get the asyncio in Python to work with the function I’ve written in JS. There is a way to directly write this function in Python but I’m not sure yet how …

Total answers: 1

Can Pyscript dynamically update the innerHTML attribute within a py-script tag?

Can Pyscript dynamically update the innerHTML attribute within a py-script tag? Question: I’ve only just started playing with Pyscript, and I’m trying to use it to dynamically update some HTML markup on my page at run-time. (I rarely program in Javascript, so there are plenty of gaps in my knowledge when it comes to programming …

Total answers: 1