当前位置:   article > 正文

golang web 文件服务器 WFS_golang 文件服务软件

golang 文件服务软件

golang 使用标准库 30行代码实现 web 文件托管服务器

WFS(Web File Server) 是一个可以通过浏览器浏览本地托管目录的在线文件服务器。

使用自定义的 ResponseBodyWriter 结构在 Write 函数中重写 http.ResponseWriter 响应内容。

运行程序,访问 http://127.0.0.1:8080/ 即可访问 exe 根目录内容。

在这里插入图片描述

package main

import (
	"bytes"
	"log"
	"net/http"
	"os"
	"path/filepath"
)

func codeStarts() string {
	return `<!DOCTYPE html>
<html>
<head>
    <title>Title</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- UIkit CSS -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/uikit@3.10
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/黑客灵魂/article/detail/1017648
推荐阅读
相关标签
  

闽ICP备14008679号