Menu

[3e9889]: / python / worker.js  Maximize  Restore  History

Download this file

31 lines (25 with data), 674 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
;(function () {
self.console = {
log: function () {}
};
self.prompt = function () {
return 'Input not supported in demo';
};
importScripts('python.opt.js');
Python.initialize(null, function(chr) {
if (chr !== null)
postMessage(String.fromCharCode(chr));
});
var msgHandler = function (e) {
if (Python.isFinished(e.data)) {
var result = Python.eval(e.data);
if (result !== null && result !== undefined) {
postMessage('\n--------------------------\nResult: ' + result);
}
} else {
postMessage('\nCommand not finished.\n');
}
};
addEventListener('message', msgHandler, false);
postMessage('Loaded');
})();
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.