Go实现一个文件服务器

作者:guoxj
浏览:432

package main

import "net/http"

func main() {
    // 启动一个文件服务器
    http.ListenAndServe(":8080", http.FileServer(http.Dir(".")))
}

其实Python也很简单,也许更简单一些,只不过需要Python的环境,可移植性不如Go这样最终产物为可执行文件的语言。不过也给个例子吧

python -m http.server 8090

 




登录后回复

共有1条评论


guoxj

Python的命令是在shell

2022-12-23 00:41 回复