Python的http。server(或SimpleHTTPServer for Python 2)是一个从命令行提供当前目录内容的好方法:
python -m http.server
然而,就网络服务器而言,它是非常缓慢的…
它的行为就像它是单线程的,并且在使用RequireJS加载JavaScript AMD模块时偶尔会导致超时错误。加载一个没有图像的简单页面可能需要5到10秒钟。
还有什么更快更方便的选择吗?
Python的http。server(或SimpleHTTPServer for Python 2)是一个从命令行提供当前目录内容的好方法:
python -m http.server
然而,就网络服务器而言,它是非常缓慢的…
它的行为就像它是单线程的,并且在使用RequireJS加载JavaScript AMD模块时偶尔会导致超时错误。加载一个没有图像的简单页面可能需要5到10秒钟。
还有什么更快更方便的选择吗?
当前回答
这是另一个。这是一个Chrome扩展
安装完成后,你可以在Chrome中创建一个新标签,然后点击左上角的app按钮来运行它
它有一个简单的gui。单击选择文件夹,然后单击http://127.0.0.1:8887链接
https://www.youtube.com/watch?v=AK6swHiPtew
其他回答
这是另一个。这是一个Chrome扩展
安装完成后,你可以在Chrome中创建一个新标签,然后点击左上角的app按钮来运行它
它有一个简单的gui。单击选择文件夹,然后单击http://127.0.0.1:8887链接
https://www.youtube.com/watch?v=AK6swHiPtew
如果使用Mercurial,则可以使用内置的HTTP服务器。在您希望提供的文件夹中:
hg serve
从文档中可以看出:
export the repository via HTTP
Start a local HTTP repository browser and pull server.
By default, the server logs accesses to stdout and errors to
stderr. Use the "-A" and "-E" options to log to files.
options:
-A --accesslog name of access log file to write to
-d --daemon run server in background
--daemon-pipefds used internally by daemon mode
-E --errorlog name of error log file to write to
-p --port port to listen on (default: 8000)
-a --address address to listen on (default: all interfaces)
--prefix prefix path to serve from (default: server root)
-n --name name to show in web pages (default: working dir)
--webdir-conf name of the webdir config file (serve more than one repo)
--pid-file name of file to write process ID to
--stdio for remote clients
-t --templates web templates to use
--style template style to use
-6 --ipv6 use IPv6 in addition to IPv4
--certificate SSL certificate file
use "hg -v help serve" to show global options
Go 1.0包含一个HTTP服务器& util,用于用几行代码提供文件。
package main
import (
"fmt"; "log"; "net/http"
)
func main() {
fmt.Println("Serving files in the current directory on port 8080")
http.Handle("/", http.FileServer(http.Dir(".")))
err := http.ListenAndServe(":8080", nil)
if err != nil {
log.Fatal("ListenAndServe: ", err)
}
}
使用go Run myserver运行这个源代码。去构建一个可执行文件去构建myserver。Go
尝试webfs,它很小,不依赖于安装node.js或python这样的平台。
试试polpetta吧…
npm install -g polpetta
然后你就可以
polpetta ~/folder
你已经准备好了:-)