How to save to a json file

Hey I am trying to have you enter a phrase into an input tag in html, and then when you press an enter button it saves the phrase to a json file. I think I could use python to do this, but don’t know how.

Is this in the browser? I’m not sure how this is specifically related to Python.

Here’s a stack overflow article that might point you in the right direction: javascript - Save html form input to json file - Stack Overflow

2 Likes

I thought I could use python with the html, and yes it is in a browser.

You can, but it depends a bit on how the web server is set up. You could use a Python framework like Flask or Tornado, for example, and then have your Python code handle any interactions with users. But saving a particular input to a json file (on the server) could just use the standard Python json module, so that part would not be different from any other Python script.

There is also Python web-assembly (see for instance: Pyodide - perhaps you were thinking of something like that?) I’ve never worked with that, but that might in principle be another way to use Python here.