-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
48 lines (34 loc) · 999 Bytes
/
main.js
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
// Third party NPM modules.
const _electron = require('electron');
const _express = require('express');
// Main controller.
const _controller = require('./lib/controller.js');
// The port express will use to serve views.
const _port = 3000;
/* --- Electron Injection Point --- */
const {app, BrowserWindow} = _electron;
app.on('ready', function() {
let win = new BrowserWindow({
width: 800,
height: 600,
autoHideMenuBar: true,
useContentSize: true,
resizable: false,
});
win.loadURL(`http://localhost:${_port}/`);
win.focus();
win.webContents.openDevTools();
});
/* --- Express Routes --- */
var e = _express();
e.use(_express.static(__dirname));
e.set('view engine', 'ejs');
e.listen(_port, function () {
console.log(`Express is listening on port ${_port}.`)
})
e.get('/', function(req, res){
res.render('encloud', {view: 'index'});
});
e.get('/files', function(req, res){
res.render('encloud', {view: 'files', files: _controller.getFiles()});
});