moserrya/knod
关于
为当前目录提供服务的轻量 HTTP 服务器。
系统与基础设施实测星标增长
- 24小时
- 0
- 7天
- -1
- 15天
- -1
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文#Knod
Knod is a simple HTTP server for prototyping rich JavaScript apps. It responds to GET, PUT, POST, PATCH, and DELETE, serving up, writing to, and deleting from the directory of your choice. Knod has no dependencies outside of the Ruby standard library.
Installation
gem install knod
Usage
The Knod gem comes with an executable; you can run it from the command line with knod. Knod will default to port 4444 and the current directory. You can change these with command line arguments (-p and -d, respectively).
You can also run it by requiring knod and calling Knod.start. Knod accepts an options hash that lets you change the port, root directory, and logging:
options = {port: 1234, root: './some/directory', logging: false}
Knod.start options
Logging is enabled by default. The server will select an open ephemeral port at random if you pass in 0 as the port.
Knod sanitizes the path on all requests and does not allow access to folders outside of the root directory where it is run.
If the path for a GET request is a file, file will be mapped to its MIME type based on the file suffix. Data is considered to be application/octet-stream if the content type is unrecognized. If the path for a GET request is a directory, Knod will concatenate the contents of all files in the directory into a JSON array.
All data from PUT, POST, and PATCH requests is stored as JSON. If the pathway specified in the request does not exist, Knod will create it.
POST requests auto-increment in the specified path and return the id of the file written as JSON (e.g if a POST request led to the server writing 56.json, the server would respond with "{\"id\":56}".
探索相关项目
加载中…
