This commit is contained in:
David Flanagan 2016-06-30 22:57:25 -07:00
Родитель ceced97c4e
Коммит 22c947cb3d
3 изменённых файлов: 44 добавлений и 4 удалений

28
index.hbs Normal file
Просмотреть файл

@ -0,0 +1,28 @@
<html>
<head>
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1"/>
<meta charset="utf-8"/>
<title>Vaani Setup</title>
</head>
<body>
<h1>Vaani Setup</h1>
<h2>WiFi</h2>
{{connectionState}}
<form action="addNetwork" method="post">
Select your wifi network:<br/>
<select name="ssid">
{{#networks}}
<option value="{{this}}">{{this}}</option>
{{/networks}}
</select>
<br/>
Enter your wifi password:<br/>
<input name="password">
<br/>
<button id="submit">Connect</button>
</form>
<h2>Evernote Authorization</h2>
</body>
</html>

Просмотреть файл

@ -1,9 +1,13 @@
var wifi = require('./wifi.js');
var express = require('express');
var bodyParser = require('body-parser');
var fs = require('fs');
var Handlebars = require('handlebars');
var app = express();
var indexPageTemplate = Handlebars.compile(fs.readFileSync('./index.hbs'));
// Serve static files in the public/ directory
// app.use(express.static('public'));
@ -18,12 +22,20 @@ app.get('/', (request, response) => {
Promise.all([wifi.getConnectedNetwork(), wifi.scan()])
.then(results => {
var connected = results[0] || 'DISCONNECTED';
var scanResults = results[1];
/*
var networkOptions = results[1]
.filter(n => n !== '')
.map(n => `<option value="${n}">${n}</option>`)
.join("\n ");
*/
response.send(indexPageTemplate({
connectionState: connected,
networks: scanResults
)});
});
response.send(
/*
`<h1>Get Your Device Online</h1>
Wifi Status: ${connected}
@ -38,8 +50,7 @@ app.get('/', (request, response) => {
<br/>
<button id="submit">Connect</button>
</form>`
);
});
*/
});
app.post('/addNetwork', (request, response) => {

Просмотреть файл

@ -19,6 +19,7 @@
"dependencies": {
"body-parser": "^1.15.2",
"evernote": "^1.25.82",
"express": "^4.14.0"
"express": "^4.14.0",
"handlebars": "^4.0.5"
}
}