CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Avatar for Testing 18.04.

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

| Download
Project: Testing 18.04
Views: 659
Kernel: Javascript (Node.js)
1+1
2
process.version
'v10.19.0'
function test(x, y) { s = [] for (var i = 0; i < x; i++) { s.push(y + i) } return s }
test(10, 23)
[ 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 ]
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(); })
{ "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "2" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "1+1" ] }
async function a() { console.log("start") await new Promise((done, fail) => setTimeout(done, 1000)); console.log("done") }
$$.async(); (async () => { await a(); $$.done(); })()
start 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);
Server { insecureHTTPParser: undefined, _events: [Object: null prototype] { request: [Function], connection: [Function: connectionListener] }, _eventsCount: 2, _maxListeners: undefined, _connections: 0, _handle: TCP { reading: false, onread: null, onconnection: [Function: onconnection], [Symbol(owner)]: [Circular] }, _usingWorkers: false, _workers: [], _unref: false, allowHalfOpen: true, pauseOnConnect: false, httpAllowHalfOpen: false, timeout: 120000, keepAliveTimeout: 5000, maxHeadersCount: null, headersTimeout: 40000, _connectionKey: '6::::8080', [Symbol(IncomingMessage)]: { [Function: IncomingMessage] super_: { [Function: Readable] ReadableState: [Function: ReadableState], super_: [Function], _fromList: [Function: fromList], from: [Function] } }, [Symbol(ServerResponse)]: { [Function: ServerResponse] super_: { [Function: OutgoingMessage] super_: [Function] } }, [Symbol(asyncId)]: 63 }

The code above then works like that: