Golang的简易半成品网盘,支持webdav 和网页浏览

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

代码https://download.csdn.net/download/qq_20081893/85388963

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
	}
}

附图

主页

添加文件夹

支持上传文件

没写删除。

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值