-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyint.html
38 lines (38 loc) · 1.25 KB
/
pyint.html
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
31
32
33
34
35
36
37
38
<!DOCTYPE html>
<html>
<head>
<!--<script src="compiled/lib/jquery-2.1.1.min.js" type="text/javascript"></script>-->
<script data-main="release/InterpretPyc" src="node_modules/requirejs/require.js"></script>
<script src="compiled/lib/browserfs.js" type="text/javascript"></script>
</head>
<body>
<h1>Python Interpreter Test</h1>
<input type="file" onchange="handleFiles(this.files)"></input>
<div id='out'>
</div>
<script type="text/javascript">
//http://www.html5rocks.com/en/tutorials/file/dndfiles/
function handleFiles(fileList){
//console.log(fileList);
//console.log(fileList[0]);
var reader = new FileReader();
reader.onload = (function(theFile){
return function(pyc){
console.log(pyc);
console.log(theFile.name);
console.log(pyc.target.result);
console.log(typeof(pyc.target.result));
localStorage.clear();
require(['compiled/src/InterpretPyc'], function(InterpretPyc){
BrowserFS.install(window);
InterpretPyc(new Buffer(pyc.target.result), function cb(){
console.log('done');
});
});
}
})(fileList[0]);
reader.readAsArrayBuffer(fileList[0]);
}
</script>
</body>
</html>