CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/main/app.js
Views: 311
/* -----------------------------------------------1/* Author : Titanium Network2/* MIT license: http://opensource.org/licenses/MIT3/* ----------------------------------------------- */45const express = require('express'),6alloy = require('alloyproxy'),7app = express(),8http = require('http'),9fs = require('fs'),10path = require('path');1112const config = JSON.parse(fs.readFileSync('./config.json', {13encoding: 'utf8'14}));1516const server = http.createServer(app);1718//Local Alloy Proxy1920const localprox = new alloy({21prefix: '/prefix/',22error: (proxy) => {23return proxy.res.send(fs.readFileSync(path.join(__dirname, 'public', 'error.html'), 'utf8'));24},25request: [],26response: [],27injection: true28});2930app.use(localprox.app);3132localprox.ws(server);3334//Cloudflare Attack Mode Fix3536app.post('/', async (req, res) => {37switch (req.url) {38case '/':39return res.send(fs.readFileSync(path.join(__dirname, 'public', 'index.html'), 'utf8'));40}41});4243//Querystring Navigation44app.get('/', async (req, res) => {4546switch (req.url) {47case '/':48return res.send(fs.readFileSync(path.join(__dirname, 'public', 'index.html'), 'utf8'));49}5051switch (req.url) {52case '/?a':53return res.send(fs.readFileSync(path.join(__dirname, 'public', 'error.html'), 'utf8'));54}5556});5758app.use(express.static(path.join(__dirname, 'public')));5960server.listen(process.env.PORT || config.port);616263