+ 2

Data Exchange Between Python and JS

So, I have a python code (That is somewhat huge) and I want a website that would take user input, send it to the python code, the python code will give output to the website according to the input and the website will then show the output to the user. The problem is that I am unable to pass the information to the python code and also cannot get it back (obviously). If u want to help, explaining the process would be much appreciated. N.B: I don't want to use Django or Flask. Also, I don't want to convert my whole python to S. Thank You

11th Sep 2021, 2:15 PM
Tanvir Salehin
Tanvir Salehin - avatar
7 odpowiedzi
+ 4
Save the data in a file that is accessible by both. E.g. a csv or json file.
11th Sep 2021, 2:35 PM
Simon Sauter
Simon Sauter - avatar
+ 2
"Csv" stands for "comma separated values". It's a very common and simple format for saving data. It's basically a table where columns are separated by commas. JSON is a bit more complex but still quite simple. From a python perspective it's basically a file that contains a dictionary which can contain dictionaries which can contain dictionaries and so on. You should find lots of websites explaining them.
11th Sep 2021, 3:57 PM
Simon Sauter
Simon Sauter - avatar
+ 1
For web, it's almost impossible or a very insane hard task, to execute python script or python file outside a python web framework! The website you are talking about which accepts user input and send it to your python file should be an API. You are trying wrong method! Start learning web development and you will realize that you trying smthg wrong! Hint: How your python file would be executed if its not inside a python environment?!
11th Sep 2021, 5:53 PM
iTech
iTech - avatar
+ 1
Sure it is more than possible. You should learn Django as it is the powerful python web framework and also you should learn Django Rest Framework or DRF to build an API. I have to say that advanced Django and DRF are not easy neither hard, you will have to practice a lot. Good Luck.
13th Sep 2021, 5:27 PM
iTech
iTech - avatar
0
I don't actually know about json or csv files... Can u suggest a website or tutorial..?? Thanks
11th Sep 2021, 3:49 PM
Tanvir Salehin
Tanvir Salehin - avatar
0
iTech Yeah.. So I was thinking if I could setup a python website/server, My html website would send data to that python website and then python would modify and send it to the html again... Can that be possible..??
12th Sep 2021, 1:15 AM
Tanvir Salehin
Tanvir Salehin - avatar
0
Thanks a lot iTech
14th Sep 2021, 12:57 AM
Tanvir Salehin
Tanvir Salehin - avatar