const { app, BrowserWindow } = require('electron');
const path = require('path');
const url = require('url');

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let win;

function createWindow() {
  // Create the browser window.
  win = new BrowserWindow();
  win.maximize();

  // and load the index.html of the app.
  win.loadURL(url.format({
    pathname: path.join(__dirname, 'start.html'),
    protocol: 'file:',
    slashes: true
  }));

  // Open the DevTools.
  win.webContents.openDevTools();

  // Emitted when the window is closed.
  win.on('closed', () => {
    // Dereference the window object, usually you would store windows
    // in an array if your app supports multi windows, this is the time
    // when you should delete the corresponding element.
    win = null;
  });
}

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow);

// Quit when all windows are closed.
app.on('window-all-closed', () => {
  // On macOS it is common for applications and their menu bar
  // to stay active until the user quits explicitly with Cmd + Q
  if (process.platform !== 'darwin') {
    app.quit();
  }
});

app.on('activate', () => {
  // On macOS it's common to re-create a window in the app when the
  // dock icon is clicked and there are no other windows open.
  if (win === null) {
    createWindow()
  }
});

@@ -1,12 +1,61 @@
+// electron main%0Aconsole.log(process.versions);%0A%0A
 const %7B app,
@@ -98,288 +98,386 @@
 ');%0A
-const path = require('path');%0Aconst url = require('url');%0A%0A// Keep a global reference of the window object, if you don't, the window will%0A// be closed automatically when the JavaScript object is garbage collected.%0Alet win;%0A%0Afunction createWindow() %7B%0A  // Create the browse
+var ipc = require('electron').ipcMain;%0A%0Aapp.on(%22ready%22, function () %7B%0A  ipc.on(%22console%22, function (ev) %7B%0A    var args = %5B%5D.slice.call(arguments, 1);%0A    var r = console.log.apply(console, args);%0A    ev.returnValue = %5Br%5D;%0A  %7D);%0A  ipc.on(%22app%22, function (ev, msg) %7B%0A    var args = %5B%5D.slice.call(arguments, 2);%0A    ev.returnValue = %5Bapp%5Bmsg%5D.apply(app, args)%5D;%0A  %7D);%0A%0A  va
 r window
 .%0A  
@@ -472,23 +472,16 @@
 r window
-.%0A  win
  = new B
@@ -505,114 +505,32 @@
  win
-.maximize();%0A%0A  // and load the index.html of the app.%0A  win.loadURL(url.format(%7B%0A    pathname: path.join(
+dow.loadURL(%22file://%22 + 
 __di
@@ -538,11 +538,13 @@
 name
-, '
+ + %22/
 star
@@ -553,90 +553,20 @@
 html
-'),%0A    protocol: 'file:',%0A    slashes: true%0A  %7D));%0A%0A  // Open the DevTools.
+%22);
 %0A  win
+dow
 .web
@@ -594,969 +594,553 @@
 ();%0A
-%0A
   
-// Emitted when the window is closed.%0A  win.on('closed', () =%3E %7B%0A    // Dereference the window object, usually you would store windows%0A    // in an array if your app supports multi windows, this is the time%0A    // when you should delete the corresponding element.%0A    win = null;%0A  %7D);%0A%7D%0A%0A// This method will be called when Electron has finished%0A// initialization and is ready to create browser windows.%0A// Some APIs can only be used after this event occurs.%0Aapp.on('ready', createWindow);%0A%0A// Quit when all windows are closed.%0Aapp.on('window-all-closed', () =%3E %7B%0A  // On macOS it is common for applications and their menu bar%0A  // to stay active until the user quits explicitly with Cmd + Q%0A  if (process.platform !== 'darwin') %7B%0A    app.quit();%0A
+window.webContents.once(%22did-finish-load%22, function () %7B%0A    var http = require(%22http%22);%0A    var crypto = require(%22crypto%22);%0A    var server = http.createServer(function (req, res) %7B%0A      var port = crypto.randomBytes(16).toString(%22hex%22);%0A      ipc.once(port, function (ev, status, head, body) %7B%0A        //console.log(status, head, body);%0A        res.writeHead(status, head);%0A        res.end(body);%0A    
   
-%7D%0A
 %7D);%0A
-%0Aapp.on('activate', () =%3E %7B%0A  // On macOS it's common to re-create a window in the app when the%0A  // dock icon is clicked and there are no other windows open.%0A  if (win === null) %7B%0A    createWindow()
+      window.webContents.send(%22request%22, req, port);%0A    %7D);%0A    server.listen(8000);%0A    console.log(%22http://localhost:8000/%22);
 %0A  %7D
+);
 %0A%7D);

add server to electron