|
|
|
|
|
by joshhug
242 days ago
|
|
This was cool: https://codepen.io/ChetasLua/pen/yyezLjN Somewhat amusing 4th wall breaking if you open Python from the terminal in the fake Windows. Examples:
1. If you try to print something using the "Python" print keyword, it opens a print dialog in your browser.
2. If you try to open a file using the "Python" open keyword, it opens a new browser tab trying to access that file. That is, it's forwarding the print and open calls to your browser. |
|
} else if (mode === 'python') { if (cmd === 'exit()') { mode = 'sh'; } else { try { // Safe(ish) eval for demo purposes. // In production, never use eval. Use a JS parser library. // Mapping JS math to appear somewhat pythonesque let result = eval(cmd); if (result !== undefined) output(String(result)); } catch (e) { output(`Traceback (most recent call last):\n File "<stdin>", line 1, in <module>\n${e.name}: ${e.message}`, true); } }