GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — multi-repl/server.js at master · seidtgeist/multi-repl

Expand file tree

/

server.js

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
52 lines (43 loc) · 1.25 KB
/

server.js

Copy path

File metadata and controls

52 lines (43 loc) · 1.25 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
51
52
var fs = require('fs');
var http = require('http');
var io = require('socket.io');
var spawn = require('child_process').spawn;
var tty = require('./fixed_tty');
var url = require('url');
var routes = {
'/':
[200, 'text/html', fs.readFileSync('client.html', 'utf8')],
'/dojo.js':
[200, 'application/json', fs.readFileSync('dojo.js', 'utf8')],
'/socket.io.min.js':
[200, 'application/json', fs.readFileSync('socket.io.min.js', 'utf8')],
not_found:
[404, 'text/plain', 'Not found.']
};
var server = http.createServer(function(req, res){
req.setEncoding('utf8');
var path = url.parse(req.url).pathname;
var route = routes[path] || routes.not_found;
res.writeHead(route[0], { 'Content-Type': route[1] });
res.end(route[2]);
});
server.listen(1337, '127.0.0.1');
var tty_handle = tty.open('ipython');
var stream = tty_handle[0];
var repl = tty_handle[1];
repl.on('exit', function(){
console.log('repl died');
});
var socket = io.listen(server, { log: false });
var buffer = ''; // how not to do a buffer.
stream.setEncoding('utf8');
stream.on('data', function(data){
buffer += data;
socket.broadcast(data);
});
socket.on('connection', function(client){
client.send(buffer);
client.on('message', function(message){
stream.write(message + '\n');
});
});
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.