- 静态文件模板
- 文件上传
- 文件查看和下载
import (
"fmt"
"html/template"
"io"
"net/http"
"os"
"path/filepath"
"regexp"
"strconv"
"time"
)
//静态文件服务器
http.FileServer(http.Dir("目录"))
//手工配置服务和路由
s := &http.Server{
Addr: ":8080",
Handler: myHandler,
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
MaxHeaderBytes: 1 << 20,
}
s.ListenAndServe();
// path/filepath包的使用
麻雀虽小,但是有很多基础知识点适合学习golang的朋友们一起玩
- static file temlate
- upload file
- To view and download files
import (
"fmt"
"html/template"
"io"
"net/http"
"os"
"path/filepath"
"regexp"
"strconv"
"time"
)
//static server
http.FileServer(http.Dir("目录"))
//Manually configure the service and routing
s := &http.Server{
Addr: ":8080",
Handler: myHandler,
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
MaxHeaderBytes: 1 << 20,
}
s.ListenAndServe();
// path/filepath The use of the package
The sparrow is small, but there are a lot of basic knowledge for learning golang friends to play together