+ 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
7 Respostas
+ 4
Save the data in a file that is accessible by both. E.g. a csv or json file.
+ 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.
+ 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?!
+ 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.
0
I don't actually know about json or csv files... Can u suggest a website or tutorial..?? Thanks
0
Thanks a lot iTech