Skip to content

Instantly share code, notes, and snippets.

@acidsound
Created March 30, 2015 15:34
Show Gist options
  • Save acidsound/4075d71b375835ce2501 to your computer and use it in GitHub Desktop.
Save acidsound/4075d71b375835ce2501 to your computer and use it in GitHub Desktop.
Static WebServer for Nodemcu - esp8266
srv=net.createServer(net.TCP, 15)
srv:listen(80, function(c)
c:on("receive", function(c, pl)
_, _, method, url, vars = string.find(pl, "([A-Z]+) /([^?]*)%??(.*) HTTP")
print(method..":"..url..":"..vars)
if file.open(url, "r")==nil then
file.open("index.html", "r")
end
c:send(file.read())
file.close()
c:close()
end)
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment