golanggo中的简单静态文件服务器(代码片段)

author author     2023-02-01     451

关键词:

/*
Serve is a very simple static file server in go
Usage:
	-p="8100": port to serve on
	-d=".":    the directory of static files to host

Navigating to http://localhost:8100 will display the index.html or directory
listing file.
*/
package main

import (
	"flag"
	"log"
	"net/http"
)

func main() 
	port := flag.String("p", "8100", "port to serve on")
	directory := flag.String("d", ".", "the directory of static file to host")
	flag.Parse()

	http.Handle("/", http.FileServer(http.Dir(*directory)))

	log.Printf("Serving %s on HTTP port: %s\n", *directory, *port)
	log.Fatal(http.ListenAndServe(":"+*port, nil))

golanggo中的基本web服务器(代码片段)

查看详情

golanggo中的基本结构(代码片段)

查看详情

golanggo中的地图声明(代码片段)

查看详情

golanggo中的表驱动测试(代码片段)

查看详情

golanggo中的字符串连接(代码片段)

查看详情

golanggo中的示例列表结构支持(代码片段)

查看详情

golanggo中的格式化打印(代码片段)

查看详情

golanggo中的无限用户反馈(代码片段)

查看详情

golanggo中的样本整数struct容器(代码片段)

查看详情

golanggo中的字符串转换示例(代码片段)

查看详情

golanggo中存在检查文件(代码片段)

查看详情

golanggo中的虚拟udp孔冲孔样本(代码片段)

查看详情

golanggo中的方法将键设置为结构(代码片段)

查看详情

golanggo(golang)中的并发安全set数据结构(代码片段)

查看详情

golanggo中的可附加intlist结构,它使用map作为其实现(代码片段)

查看详情

golanggolang构建简单的服务器,和静态文件(代码片段)

查看详情

golanggo的反思例子(代码片段)

查看详情

golanggo_csv(代码片段)

查看详情