使用golang的建议网盘,以前学习写的半成品,最近清理旧文件,特此上传。

package main

import (
	. "EasyDeviceServer/config"
	"fmt"
	"net/http"
)

var c Conf

func main() {
	c.GetConf()
	fmt.Println("Name:" + c.Name)
	fmt.Println("Password:" + c.Password)
	fmt.Println("Host:" + c.Host)
	fmt.Println("Port:" + c.Port)
	fmt.Println("DavPath:" + c.DavPath)
	fmt.Println("WebPath:" + c.WebPath)

	//静态文件处理
	http.Handle("/css/", http.StripPrefix("/css/", http.FileServer(http.Dir("./static/css"))))
	http.Handle("/js/", http.StripPrefix("/js/", http.FileServer(http.Dir("./static/js"))))
	http.Handle("/images/", http.StripPrefix("/images/", http.FileServer(http.Dir("./static/images"))))

	http.HandleFunc("/", index)

	// rutor need /webda/ ,others /webdav/data will to /
	http.HandleFunc("/webdav/", dealWebDav)

	http.HandleFunc("/get_dir_file", getDirFile)
	http.HandleFunc("/login", login)
	http.HandleFunc("/upload", upload)
	http.HandleFunc("/add_folder", addFolder)

	err := http.ListenAndServe(c.Host+":"+c.Port, nil)
	if err != nil {
		fmt.Println("服务器启动失败", err.Error())
		return
	}
}

附图

主页

添加文件夹

支持上传文件

没写删除。

后台文件直接以文件夹的方式管理,没有详细的文件后台管理模块。