Call Python function in HTML, JS
How can I call a Python function in HTML or JavaScript?
Thanks
Voters
ruiwenge2
also why do you need to use Python?
VulcanWM
I need Python for the account storage and stuff bc I’m more comfortable with that and JS for the main game
@ruiwenge2ruiwenge2
try using brython
VulcanWM
okay I’ll try that
@ruiwenge2
Since Python can't run in the browser, you'll need to set up a server to run the Python function, which you can request in JavaScript.
Here is a basic example using the Flask framework:
Run that on a separate repl, then copy its' URL. Now, request it using JavaScript's fetch API:
oh okay thanks I’ll try that
@xfinnbarwhat about in a HTML JS repl?
it works thank you!
@xfinnbar