Ask
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News Sign UpSign In
Project: Testing 18.04
Views: 529
Embed | Download | Raw |
Kernel: Javascript (Node.js)
1+1
process.version
function test(x, y) { s = [] for (var i = 0; i < x; i++) { s.push(y + i) } return s }
test(10, 23)
const fs = require("fs")
$$.async(); fs.readFile("javascript.ipynb", "utf8", (err, data) => { const nb = JSON.parse(data); console.log(JSON.stringify(nb.cells[1], null, 2)); $$.done(); })
async function a() { console.log("start") await new Promise((done, fail) => setTimeout(done, 1000)); console.log("done") }
$$.async(); (async () => { await a(); $$.done(); })()

Little HTTP Server

Open it up at https://cocalc.com/[YOUR PROJECT ID]/server/8080

more info: https://doc.cocalc.com/howto/webserver.html

var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end(`Hello World!\nIt's ${new Date().toISOString()}`); }).listen(8080);

The code above then works like that: