A long time ago, I wanted to make an online IDE, a nodejs of the previous period, made a simple version
Login, registration, Code Editor (highlighting, auto-Lenovo), cloud compilation and other functions are now completed.
Front end I mainly use bootstrap, Codemirror
The back end is mainly Nodejs
Compiler is g++
All stations are fully static, so requests are AJAX simulations
Below is the source code of Server.js
Other can be coding to view the project
Https://git.coding.net/leeli73/CorCPP_Online_IDE.git
Because many of the files in the naming, I used-and coding in the special characters can not be a file name, so the project Www.zip is the site's front-end code
Server.js is a server script
There are a lot of questions, I hope the jackpot will help me find bugs and perfect features
varWebsocketserver = require (' WS '). Server, WSS=NewWebsocketserver ({port:88}); Wss.on (' Connection ',function(WS) {Console.log (' Client Connected '); Ws.on (' Message ',function(message) {console.log (message); Responsejson (message); });});functionResponsejson (str) {varData =json.parse (str); if(Data.type = = "Code") {Response_code (data.data); } Else if(Data, Type = = "Get") { }}functionResponse_code (Code) {varFS = require ("FS"); Fs.writefile (' Gcc\code\code.txt ', code,function(err) {if(err) {returnConsole.error (ERR); }}) Fs.readfile (' Gcc\code\code.txt ',function(err, data) {if(err) {returnConsole.error (ERR); } console.log ("DATA is:" +data.tostring ()); }) varcmd = require ("Node-cmd"); /*cmd.get (' c:\\users\\leeli\\documents\\visual Studio 2017\\projects\\server\\server\\gcc\\check.exe C:\\Users\ \leeli\\documents\\visual Studio 2017\\projects\\server\\server\\gcc\\code\\code.txt ', function (data) {Console . log (data); });*/Cmd.run (' E:\server\server\gcc\check.exe E:\server\server\gcc\code\code.txt ');}
[NodeJS] WebSocket-based NodeJS on-line webide and online compilation