-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
50 lines (47 loc) · 1.63 KB
/
index.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
39
40
41
42
43
44
45
46
47
48
49
50
<!doctype html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/pyodide/v0.24.1/full/pyodide.js"></script>
<title>Pyodide CLI Test</title>
</head>
<body>
<script type="text/javascript">
async function main(){
let pyodide = await loadPyodide();
await pyodide.loadPackage("micropip")
console.log(await pyodide.runPythonAsync(`
# Pyodide Installs
import micropip
await micropip.install('reddit-post-scraping-tool==1.9.1.1')
await micropip.install('pyodide-http')
# Monkey patch requests
import pyodide_http
pyodide_http.patch_all()
# Normal python imports
import sys
from unittest.mock import patch
from rpst.main import run
`
));
console.log(pyodide.runPython(`
with patch.object(
sys,
'argv',
[
'rpst',
'--listing','new',
'--limit','20',
'--subreddit', 'bellingcat',
'--keyword', 'bellingcat'
]
):
run()
`
));
}
main();
</script>
<h1>Pyodide CLI Test</h1>
<p>Open your browser console to view the output. You may need to use <a href="https://www.google.com/chrome/">Google Chrome</a> with the <a href="https://chromewebstore.google.com/detail/cross-domain-cors/mjhpgnbimicffchbodmgfnemoghjakai">Cross Domain - CORS Extension</a>.</p>
</body>
</html>