Further webserver stuff

This commit is contained in:
C3MA 2016-12-17 02:09:23 +01:00
parent cdcd37a997
commit 4b1cea0224
2 changed files with 41 additions and 3 deletions

View File

@ -15,6 +15,8 @@
<tr><th>4. Minute Color</th><td><input type=\"color\" name=\"colorMin4\" value=\"" .. hexColor4 .. "\"></td><td /></tr>"
<tr><th>Three quater</th><td><input type="checkbox" name="threequater" ${THREEQUARTERCHECKED}></td><td>Dreiviertel Joa/nei</td></tr>
<tr><th>ColorMode</th><td><input type="checkbox" name="colorMode" ${COLORMODECHECKED}></td><td>If checked, words are dark, rest is colored</td></tr>
<tr><td colspan=\"3\"><div align=\"center\"><input type=\"submit\" value=\"Save Configuration\" onclick=\"this.value='Submitting ..';this.disabled='disabled'; this.form.submit();\"></div></td></tr>"
<tr><td colspan=\"3\"><div align=\"center\"><input type=\"submit\" name=\"action\" value=\"Reboot\"></div></td></tr>"
</table></form>"
<tr><td colspan="3"><div align="center"><input type="submit" value="Save Configuration" onclick="this.value='Submitting ..';this.disabled='disabled'; this.form.submit();"></div></td></tr>
<tr><td colspan="3"><div align="center"><input type="submit" name="action" value="Reboot"></div></td></tr>
</table></form>
$ADDITIONAL_LINE
</body></html>

View File

@ -2,6 +2,42 @@
configFile="config.lua"
sentLines=0
sendFile=nil
function sendPage(conn, nameOfFile)
if (sentLines > 0) then
print("There is a site already sent")
return
end
sendFile=nameOfFile
if file.open(sendFile, "r") then
local line = file.readLine()
-- TODO replace the tokens in the line
local buf=""
while (line ~= nil) do
buf = buf .. line
sentLines= sentLines+1
-- Sent after 1k data
if (string.len(buf) >= 1000) then
line=nil
conn.send(buf)
else
-- fetch the next line
line = file.readLine()
end
end
end
conn:on("sent", function(conn)
conn:close()
-- Clear the webpage generation
sendWebPage=nil
print("Clean webpage from RAM")
end)
end
function startWebServer()
srv=net.createServer(net.TCP)
srv:listen(80,function(conn)