在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:marcoskirsch/nodemcu-httpserver开源软件地址:https://github.com/marcoskirsch/nodemcu-httpserver开源编程语言:Lua 63.4%开源软件介绍:nodemcu-httpserverA (very) simple web server written in Lua for the ESP8266 running the NodeMCU firmware.
Let the abuse begin. Features
How to use
HTTP Basic Authentication.It's supported. Turn it on in httpserver-conf.lua. Use it with care and don't fall into a false sense of security: HTTP Basic Authentication should not be considered secure since the server is not using encryption. Username and passwords travel in the clear. Server-side scripting using your own Lua scriptsYes, you can upload your own Lua scripts! This is pretty powerful. Just put it under http/ and upload it. Make sure it has a .lua extension. Your script should return a function that takes three parameters:
Use the connection parameter to send the response back to the client. Note that you are in charge of sending the HTTP header, but you can use the bundled httpserver-header.lua script for that. See how other examples do it. The req parameter contains information about the request. The args parameter is a Lua table that contains any arguments sent by the client in the GET request. For example, if the client requests http://2.2.2.2/foo.lua?color=red then the server will execute the function in your Lua script foo.lua and pass in connection and args, where args.color = "red". LFS support.NodeMCU allows to run Lua scripts from LFS in order to save RAM resources. nodemcu-httpserver makes it easy to move your code to LFS. In order to run nodemcu-httpserver from LFS:
Example: Garage door openerPurposeThis is a bundled example that shows how to use nodemcu-httpserver together with server-side scripting to control something with the ESP8266. In this example, we will pretend to open one of two garage doors. Your typical garage door opener has a wired remote with a single button. The button simply connects to two terminals on the electric motor and when pushed, the terminals are shorted. This causes the motor to open or close. Hardware descriptionThis example assumes that you are using a Wemos D1 Pro with two relay shields and two reed switches. The relays are controlled by the microcontroller and act as the push button, and can actually be connected in parallel with the existing mechanical button. The switches are wired so that the ESP8266 can tell whether the doors are open or closed at any given time. Software descriptionThis example consists of the following files:
Security implicationsBe careful permanently installing something like this in your home. The server provides no encryption. Your only layers of security are the WiFi network's password and simple HTTP authentication (if you enable it) which sends your password unencrypted. This script is provided for educational purposes. You've been warned. Not supported
ContributingSince this is a project maintained in my free time, I am pretty lenient on contributions. I trust you to make sure you didn't break existing functionality nor the shipping examples and that you add examples for new features. I won't test all your changes myself but I am very grateful of improvements and fixes. Open issues in GitHub too, that's useful. Please keep your PRs focused on one thing. I don't mind lots of PRs. I mind PRs that fix multiple unrelated things. Follow the coding style as closely as possible:
Notes on memory usage.The chip is very, very memory constrained.
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论