2 Commits

Author SHA1 Message Date
Godzil
363c7a8dd5 Use file.exists instead of open/close when relevant 2017-09-05 15:03:23 +01:00
Manoël Trapier
b5baf6cd48 Fix mistake in config file (#107) 2017-09-04 20:42:47 -05:00
3 changed files with 11 additions and 11 deletions

View File

@@ -3,8 +3,7 @@
-- Author: Marcos Kirsch
local compileAndRemoveIfNeeded = function(f)
if file.open(f) then
file.close()
if file.exists(f) then
print('Compiling:', f)
node.compile(f)
file.remove(f)

View File

@@ -20,9 +20,10 @@ if (conf.wifi.mode == wifi.SOFTAP) or (conf.wifi.mode == wifi.STATIONAP) then
conf.wifi.accessPoint.config = {}
conf.wifi.accessPoint.config.ssid = "ESP-"..node.chipid() -- Name of the WiFi network to create.
conf.wifi.accessPoint.config.pwd = "ESP-"..node.chipid() -- WiFi password for joining - at least 8 characters
conf.wifi.accessPoint.net = {}
conf.wifi.accessPoint.net.ip = "192.168.111.1"
conf.wifi.accessPoint.net.netmask="255.255.255.0"
conf.wifi.accessPoint.net.gateway="192.168.111.1" }
conf.wifi.accessPoint.net.gateway="192.168.111.1"
end
-- These apply only when connecting to a router as a client
if (conf.wifi.mode == wifi.STATION) or (conf.wifi.mode == wifi.STATIONAP) then

View File

@@ -61,19 +61,19 @@ return function (port)
uri.args = {code = 400, errorString = "Bad Request", logFunction = log}
fileServeFunction = dofile("httpserver-error.lc")
else
local fileExists = file.open(uri.file, "r")
file.close()
local fileExists = false
if not fileExists then
if not file.exists(uri.file) then
-- print(uri.file .. " not found, checking gz version...")
-- gzip check
fileExists = file.open(uri.file .. ".gz", "r")
file.close()
if fileExists then
--print("gzip variant exists, serving that one")
if file.exists(uri.file .. ".gz") then
-- print("gzip variant exists, serving that one")
uri.file = uri.file .. ".gz"
uri.isGzipped = true
fileExists = true
end
else
fileExists = true
end
if not fileExists then