Created
March 30, 2015 15:34
-
-
Save acidsound/4075d71b375835ce2501 to your computer and use it in GitHub Desktop.
Static WebServer for Nodemcu - esp8266
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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