| Crates.io | netpup |
| lib.rs | netpup |
| version | 1.2.10 |
| created_at | 2025-01-27 19:09:32.877819+00 |
| updated_at | 2025-02-12 19:41:50.001542+00 |
| description | Super easy && simple http server |
| homepage | https://crates.io/crates/netpup |
| repository | https://github.com/MOBSkuchen/netpup |
| max_upload_size | |
| id | 1532747 |
| size | 68,492 |
Netpup can do all of that and more!
Install netpup using cargo: cargo install netpup
Or if you're on windows you can download Netpup from the releases page on the github page.
Or (for other platforms), you can build it from source.
After installing, create your config toml file:
ip = "127.0.0.1" # REQUIRED | IP.
port = 5000 # OPTIONAL | Port. Defaults to 8080.
cwd = "/path/to/my/stuff" # OPTIONAL | Set current working directory.
[logger] # OPTIONAL | Logger configuration.
print = true # OPTIONAL | Whether to print or not. Defaults to true.
log_file = 'logfile.log' # OPTIONAL | File to log to. If not specified, netpup will not log to a file.
[routes.main] # New Route -> "main" | Name must be unique, but is not important.
methods = ["GET"] # OPTIONAL | List of methods (GET, POST).
url = "/" # REQUIRED | Url to access.
path = "mainpage.html" # REQUIRED | Path to serve from.
content_type = "text/html" # OPTIONAL | Specify response content type. Netpup willl try to infer this, if not provided
# Make sure that routes with '*' come last
[routes.resources] # New Route -> "resources" | Name must be unique, but is not important.
methods = ["GET"] # OPTIONAL | List of methods (GET, POST).
url = "/r/*" # REQUIRED | Url to access. '*' means anything can come after that.
path = "/resources/*" # REQUIRED | Path to serve from. '*' means that the '*' part of the url gets inserted here.
[errors.404] # OPTIONAL | Route for Error 404's.
path = "errors/error_404.html" # REQUIRED | Path to serve from.
Then run netpup my-config.toml or netpup (config file path defaults to config.toml)
Instead of serving a static file, netpup can run a lua program serve its output.
Just provide the path to a lua file as a script in your route.
[routes.main]
methods = ["GET"]
url = "/*"
script = "main_page.lua"
Your lua program gets treated as a function:
ret = {
["code"] = 200,
["resp"] = "OK",
["headers"] = {},
["content"] = read("logfile.log"),
["type"] = "html"
}
log_info("Hi (triggered from Lua)")
return ret
The program must return a table in this format:
Additionally, netpup provides the program with the following functions: