Python and JavaScript basic communication [closed] - javascript

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I have a local HTML page: leaflet.html, which is displayed in an embedded browser inside a python-tkinter application.
Inside leaflet.html there is a simple JavaScript piece of code that contains a function:
addMarkerIn(longitude, latitude)
{
}
It is not important what this function does, what I need is to call addMarkerIn from python when a specific event occurs. Is it possible to avoid building a full http server environment and communicate through other methods such as named pipes?

You can add socket connection between js on html page and python backend. Using some library (like socket.io) it seems to be the simplest way.

Maybe this answer I wrote once helps you out?
You could make a function in python called addMarkerIn and call it with subprocess

Related

How can I remove dead JS code sent to the browser by PHP? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 17 days ago.
Improve this question
Well, I made a little research and decided to remove dead code with Tree Shivering, but it turned out that all JS scripts with HTML are sent by PHP to the browser and it doesn't work with npm run build or something. I don't know how to remove dead code, if only manually. The project runs on Open Server and I can't see what is going on on my terminal. Any suggestions?
The PHP runs serverside, the JavaScript clientside.
The JavaScript is never called by PHP. Instead, it's send to the client (the browser) together with the HTML generated by PHP. The browser executes the JavaScript.
A method like Tree Shivering, will not be able to tell you what part of the JS is not used.

Would it be possible to convert a NodeJS function to plain Javascript [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Im currently playing with the following thing: http://cgbystrom.com/articles/deconstructing-spotifys-builtin-http-server/, I want to be able to access the SpotifyWebHelper with Javascript, people have build this in NodeJS but I wonder if this is possible in plain JavaScript. Can anyone give me some pointers to start with? Or is this not possible at all?
NodeJS version:
https://github.com/onetune/spotify-web-helper/blob/master/index.js
Node.js is "plain Javascript", the only difference between Node.js and everything else is it has access to the actual computer instead of being trapped in a web sandbox.
If you mean "can I make this work in a browser?" the answer is no. It needs to be able to spawn processes, which you can't do in a browser.

best way to communicate javascript and C++ [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
how can I communicate javascript with C++, run some commands, get active processes, but I didn't find any information on the web.
What I saw is the following links but none helps me:
http://comunidad.aisoy.es/api/Communication.html
http://www.mosync.com/docs/sdk/js/guides/wormhole/extending-javascript-with-cpp/index.html
http://www.codeguru.com/cpp/i-n/ieprogram/article.php/c4399/JavaScript-Calls-from-C.htm
Based on your tiny requirements description, here's a brief overview:
Run your C++ code as a stripped down version of http server, OR better write a C++ apache module. Make your javascript to make AJAX request to the exposed URL by the C++ http server, return the response in JSON/XML.
Just the standard way for your UI (javascript) to speak to the backend (C++)

How to send/get data from one local html file to another jusing Java script [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Pls help me.. I want to send a data from a variable form one html file to another. with out using internet.. the html file will be run in a android webVIew. thank you No PHP pls
It's not possible. but you can use url params file2.html?key=value&anotherKey=value
It’s not possible to share data between files, since dead files are by no means applications capable of handling data. It takes a browsing context to make them alive.
If you can’t use any underlying code to pass the data between documents, then your best shot is to pass the data between browsing contexts (inside a single webView those would be frames I guess.)

Example Sign-up/Sign in using node.js [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I'm new on using node.js
Surfing around the web i couldn't find any example of code of a simple sign-up/sign-in that could also show me how to manage database in node.
I mean the app.js page for server and the related client-side html page, and their relation. Can someone help me or give some useful link i couldn't find?
using Cassandra and i.o. socket, it'd be the best help.
You can use Passport library http://passportjs.org/ , there should be an example there. You can also use https://npmjs.org/package/passport.socketio if you want to login by socket.io
I recommend using http://passportjs.org
It has support for simple username/password authentication as well as OAuth etc
http://passportjs.org/guide/username-password/
There's also a good tutorial here:
http://danialk.github.io/blog/2013/02/23/authentication-using-passportjs/

Categories