@@ -20,7 +20,7 @@ function page(res, headline, text, cb) {
2020 res . write ( getHeader ( 200 , 'Content-type: text/html\r\n' ) ) ;
2121 res . write ( '<!doctype html><html><head><title>esp32-javascript</title>' ) ;
2222 res . write ( '<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">' ) ;
23- res . write ( '<link rel="stylesheet" href="/style.css.gz "></head>' ) ;
23+ res . write ( '<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pure/1.0.1/pure-min.css "></head>' ) ;
2424 res . write ( '<body><div class="pure-g"><div class="pure-u-1"><div class="l-box"><h1>' ) ;
2525 res . write ( headline ) ;
2626 res . write ( '</h1>' ) ;
@@ -41,13 +41,9 @@ function startConfigServer() {
4141 console . debug ( '401 response' ) ;
4242 res . write ( getHeader ( 401 , 'WWW-Authenticate: Basic realm="Enter credentials"\r\n' ) ) ;
4343 res . end ( '401 Unauthorized' ) ;
44- } else if ( req . path === '/restart' ) {
45- if ( req . method === 'GET' ) {
46- page ( res , 'Request restart' , '<form action="/restart" method="post"><input type="submit" value="Restart" /></form>' ) ;
47- } else {
48- page ( res , 'Restarting...' , '' , function ( ) { setTimeout ( restart , 1000 ) } ) ;
49- }
50- } else if ( req . path === '/setup' ) {
44+ } else if ( req . path === '/restart' && req . method === 'POST' ) {
45+ page ( res , 'Restarting...<br /><a href="/">Home</a>' , '' , function ( ) { setTimeout ( restart , 1000 ) } ) ;
46+ } else if ( req . path === '/setup' || req . path === '/restart' ) {
5147 if ( req . method === 'GET' ) {
5248 page ( res , 'Setup' , [ '<form class="pure-form pure-form-stacked" action="/setup" method="post"><fieldset>' ,
5349 '<label for="ssid">SSID</label><input type="text" name="ssid" value="' , el_load ( 'config.ssid' ) , '" />' ,
@@ -56,7 +52,9 @@ function startConfigServer() {
5652 '<label for="offline" class="pure-checkbox"><input type="checkbox" name="offline" value="true" ' ,
5753 ( el_load ( 'config.offline' ) === 'true' ? 'checked' : '' ) , '/> Offline Mode</label>' ,
5854 '<textarea name="script">' , el_load ( 'config.script' ) , '</textarea>' ,
59- '<input type="submit" class="pure-button pure-button-primary" value="Save" /></fieldset></form>' ] ) ;
55+ '<input type="submit" class="pure-button pure-button-primary" value="Save" /></fieldset></form>' ,
56+ '<h1>Request restart</h1>' ,
57+ '<form action="/restart" method="post"><input type="submit" class="pure-button pure-button-primary" value="Restart" /></form>' ] ) ;
6058 } else {
6159 var config = http . parseQueryStr ( req . body ) ;
6260 el_store ( 'config.ssid' , config . ssid ) ;
0 commit comments