remotepy
v1.0.10
Published
JavaScript library to connect to RemotePy server. Allows you to call python functions on server from JavaScript.
Downloads
16
Maintainers
Readme
remotepy_jsclient
Remote Py allows you to write python functions and run it on a server. It also provides you interfaces in multiple languages including JavaScript, CSharp and Python to call the remote python functions.
It is a RPC mechanism built on top of Web Sockets allowing you to communicate both ways.
####Requirements
Please make sure you have a remotepy server that you are connecting to.
####Installation instructions
npm install remotepy
####Sample JavaScript client
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Remotepy Test Page</title>
<script type="module">
import { RemotePyClient } from 'https://unpkg.com/[email protected]/build/remotepy.minobs.js';
const client = new RemotePyClient('ws://server:port');
const remotepy = client.getServerAPI();
window.onload = function() {
client.connect();
}
client.onopen = function() {
remotepy.add(2, 3, function(sum) {
alert(sum);
});
}
client.onclose = function() {
divStatus.innerHTML = 'connection closed';
}
</script>
</head>
<body>
<div id="divStatus"/>
</body>
</html>