D
D
Danil Gorev2019-09-22 02:56:21
Python
Danil Gorev, 2019-09-22 02:56:21

How to run python script from javascript?

Bottom line: there is an extension for chrome that uses a lot of different api through javascript, but I don’t know this language well and can’t work with it correctly, so I want to omit all the work below, ideally to take it to python.
I understand that the best solution to my problem is a python server on sockets, or perhaps a server on flask. I can put the micro-server in the project files, it wouldn't take up much space, but I don't know how to run it after that.
Is there any easy way to run python script in background from js?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
D
Danil Gorev, 2019-09-25
@ketovv

After some time, I found a suitable solution for this task: use brython!
-> https://brython.info/

P
profesor08, 2019-09-22
@profesor08

Write javascript in python. That is, you write your code in python, and then translate it into javascript. But you must understand that it will not be possible to use all available means, since the code will be executed in the browser, and you will be limited by the capabilities of js in the browser.
But seriously, all this hassle is not worth messing around with. You still have to stick how this or that thing works in js, and then reproduce it in python. Seriously, spend a day on javascript.

K
Karpion, 2019-09-22
@Karpion

Where should all this be used? Are you going to run it for yourself? It will work somewhere in one office? Or will it be distributed to just anyone, like MS-Office and other programs (paid or free)?
As a rule, in such cases, the user (or, if it is in an organization, then the system administrator) is offered to start the server process in the way that is convenient for him. Or during installation - the installer prescribes the start of the server in autostart.

D
Developer, 2019-09-22
@samodum

JS in the browser is the client. And the client cannot directly run the server code (if the code is not full of holes), even if it is in python.
Make an API that, when accessed through JS, will run Python code

A
Alexander +, 2019-09-22
@AlexanderMi

Extensions are written by javascript, alas.
If you really need to, deploy a local web server on anything, and drive requests to it from Javascript through XmlHttpRequest, but you still need to process the request results in the extension. Again, by itself, such an extension will no longer live.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question