Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/index.js
Views: 327
// Get http, fs, and path1const http = require('http');2const fs = require('fs');3const path = require('path');45// Log6console.log("Server Running (Hopefully)")78// Start a server at port 80009http.createServer((request, response) => {10console.log(request.url);1112// Check if this is a mod.js request13if (request.url == "/shellshock.min.js"){14// Set Content Type15let contentType = "text/javascript";16// Define file path (You can change if you place file in another location)17let filePath = "." + request.url;18// Read file19fs.readFile(filePath, (error, content) => {20if (error){21if (error.code == 'ENOENT'){22console.error("Mod.js file is not found!");23response.writeHead(200, {'Content-Type': contentType});24response.end('', 'utf-8');25}else {26console.error("No Idea : " + error.code);27response.writeHead(200, {'Content-Type': contentType});28response.end('', 'utf-8');29}30}else {31response.setHeader('Access-Control-Allow-Origin', '*');32response.setHeader('Access-Control-Allow-Methods', 'GET, POST');33response.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');34response.setHeader('Access-Control-Allow-Credentials', true);35response.writeHead(200, {'Content-Type': contentType});36response.end(content, 'utf-8');37}38});39}else {40response.writeHead(200, {'Content-type':'text/plan'});41response.write('Invalid URL Try : http://localhost:8000/mod.js');42response.end();43}44}).listen(8000);454647