13 Star 62 Fork 22

YilongLi/goFileView

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.go 3.07 KB
一键复制 编辑 原始数据 按行查看 历史
YilongLi 提交于 5年前 . fix cache monitor bug
/*package main
import(
"github.com/leeli73/goFileView/perview"
)
func main() {
perview.Init("/perview/","0.0.0.0:8089")
perview.StartServer()
}*/
package main
import (
"net/http"
"github.com/leeli73/goFileView/perview"
)
func index(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`<!DOCTYPE html>
<html>
<head>
<title>goFileView测试服务</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js"></script>
<script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2>goFileView</h2>
<p>测试的预览服务</p>
<table class="table">
<thead>
<tr>
<th>文件名</th>
<th>文件类型</th>
<th>调用接口</th>
<th>预览</th>
</tr>
</thead>
<tbody>
<tr>
<td>test.docx</td>
<td>docx</td>
<td>http://gofileview.onlinecode.cn/perview/onlinePreview?url=http://onlinecode.cn/test.docx</td>
<td>
<a
href="http://gofileview.onlinecode.cn/perview/onlinePreview?url=http://onlinecode.cn/test.docx">普通预览</a>
<a
href="http://gofileview.onlinecode.cn/perview/onlinePreview?url=http://onlinecode.cn/test.docx&type=pdf">PDF预览</a>
</td>
</tr>
<tr>
<td>test.xlsx</td>
<td>xlsx</td>
<td>http://gofileview.onlinecode.cn/perview/onlinePreview?url=http://onlinecode.cn/test.xlsx</td>
<td><a
href="http://gofileview.onlinecode.cn/perview/onlinePreview?url=http://onlinecode.cn/test.xlsx">普通预览</a>
<a
href="http://gofileview.onlinecode.cn/perview/onlinePreview?url=http://onlinecode.cn/test.xlsx&type=pdf">PDF预览</a>
</td>
</tr>
<tr>
<td>test.pptx</td>
<td>pptx</td>
<td>http://gofileview.onlinecode.cn/perview/onlinePreview?url=http://onlinecode.cn/test.pptx</td>
<td><a
href="http://gofileview.onlinecode.cn/perview/onlinePreview?url=http://onlinecode.cn/test.pptx">普通预览</a>
<a
href="http://gofileview.onlinecode.cn/perview/onlinePreview?url=http://onlinecode.cn/test.pptx&type=pdf">PDF预览</a>
</td>
</tr>
<tr>
<td>test.pdf</td>
<td>pdf</td>
<td>http://gofileview.onlinecode.cn/perview/onlinePreview?url=http://onlinecode.cn/test.pdf</td>
<td><a
href="http://gofileview.onlinecode.cn/perview/onlinePreview?url=http://onlinecode.cn/test.pdf">普通预览</a>
<a
href="http://gofileview.onlinecode.cn/perview/onlinePreview?url=http://onlinecode.cn/test.pdf&type=pdf">PDF预览</a>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>`))
}
func main() {
perview.Init("/perview/", "no") //初始化
http.HandleFunc("/", index)
http.HandleFunc("/perview/", perview.Handle) //绑定到preview的Handle
http.ListenAndServe(":80", nil)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/leeli73/goFileView.git
git@gitee.com:leeli73/goFileView.git
leeli73
goFileView
goFileView
master

搜索帮助