@acadci/httpster 中文文档教程
httpster
用于快速加载内容的简单 http 服务器。
安装是通过 npm 完成的,它在大多数平台上与 NodeJS 一起安装。
npm -g install httpster
然后从您想要运行 http 服务的任何目录,只需运行
httpster
这将在端口 3333 上启动一个 Web 服务器,并让您提供您想要的任何静态内容。 如果要更改服务器运行的端口或目录,请传入 -p 或 -d 选项
httpster -p 8080 -d /home/somedir/public_html
HTML5 Pushstates
如果要运行支持 HTML5 Pushstates(也就是能够刷新页面)的本地站点,请传入选项 < code>-s 或 --pushstate
。 这会将所有 4oh4 映射到您指定为根目录的 index.html
。
Basic Authentication
由于您可以使用 httpsster 部署到像 heroku 这样的 PaaS 提供商,您现在可以使用基本身份验证来保护这些部署。 -b
或 --basic_auth
选项将从您的环境中读取 HTTPSTERAUTHUSER 和 HTTPSTERAUTHPASS 变量用于身份验证。
httpster -b
或者 httpsster --basic_auth
如果在本地进行测试,您还可以在将运行 httpsster 的目录中使用 .env 文件。
HTTPSTER_AUTH_USER=desired_username
HTTPSTER_AUTH_PASS=desired_password
然后使用 -e
或 --env
选项指定加载环境变量
httpster --env --basic_auth
Contributions
如果您有任何问题,请随时在这里添加票证。 如果您对可以使它更有用的功能有任何建议,请随时告诉我。
感谢@GarthDB 提出这个要求并让我意识到我也需要它。
httpster
Simple http server for quick loading of content.
Installation is done via npm, which is installed along with NodeJS on most platforms.
npm -g install httpster
Then from any directory where you want to have an http service running, just run
httpster
That will start up a web server on port 3333 and let you serve up any static content you wish. If you want to change the port or directory that the server runs from pass in the -p or -d options
httpster -p 8080 -d /home/somedir/public_html
HTML5 Pushstates
If you want to run a local site that supports HTML5 Pushstates (aka being able to refresh the page), pass in the option -s
or --pushstate
. This will map all 4oh4's to the index.html
you specified as root directory.
Basic Authentication
Since you can use httpster to deploy to PaaS providers like heroku you can now secure those deployments with basic authentication. The -b
or --basic_auth
options will read the HTTPSTERAUTHUSER and HTTPSTERAUTHPASS variables from your environment for authentication.
httpster -b
or httpster --basic_auth
If testing this locally you can also use a .env file in the directory you will run httpster from.
HTTPSTER_AUTH_USER=desired_username
HTTPSTER_AUTH_PASS=desired_password
Then use the -e
or --env
option to specify to load the environmental variables
httpster --env --basic_auth
Contributions
If you have some issue please feel free to add a ticket here. If you have any suggestions for features that would make this more useful please feel free to let me know.
Thanks to @GarthDB for asking for this and making me realize that I needed it too.