v 1.0.1
parent
408c4aa45b
commit
a77ff9c25a
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="PublishConfigData" remoteFilesAllowedToDisappearOnAutoupload="false">
|
||||
<serverData>
|
||||
<paths name="root@10.0.0.13:22">
|
||||
<serverdata>
|
||||
<mappings>
|
||||
<mapping local="$PROJECT_DIR$" web="/" />
|
||||
</mappings>
|
||||
</serverdata>
|
||||
</paths>
|
||||
<paths name="root@118.220.175.207:22 password">
|
||||
<serverdata>
|
||||
<mappings>
|
||||
<mapping local="$PROJECT_DIR$" web="/" />
|
||||
</mappings>
|
||||
</serverdata>
|
||||
</paths>
|
||||
</serverData>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GitToolBoxProjectSettings">
|
||||
<option name="commitMessageIssueKeyValidationOverride">
|
||||
<BoolValueOverride>
|
||||
<option name="enabled" value="true" />
|
||||
</BoolValueOverride>
|
||||
</option>
|
||||
<option name="commitMessageValidationEnabledOverride">
|
||||
<BoolValueOverride>
|
||||
<option name="enabled" value="true" />
|
||||
</BoolValueOverride>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,50 @@
|
|||
## 推荐环境 Linux Python3.11
|
||||
|
||||
### 安装
|
||||
`mkdir -p /python&&cd /python`
|
||||
|
||||
`wget https://git.fynn.vip/fynn/onlyoffice-cloudreve/-/archive/master/onlyoffice-cloudreve-master.zip`
|
||||
- **或者使用git克隆**
|
||||
|
||||
`git clone https://git.fynn.vip/fynn/onlyoffice-cloudreve.git`
|
||||
#### 进入目录
|
||||
```
|
||||
unzip onlyoffice-cloudreve-master.zip -d onlyoffice-cloudreve
|
||||
cd onlyoffice-cloudreve
|
||||
```
|
||||
- **或者**
|
||||
|
||||
`cd onlyoffice-cloudreve`
|
||||
|
||||
#### 安装第三方库
|
||||
`pip3 install -r requirements.txt`
|
||||
|
||||
#### 启动脚本
|
||||
`sanic main:app --host=0.0.0.0 --port=8000`
|
||||
|
||||
#### 创建服务
|
||||
`vim /usr/lib/systemd/system/onlyoffice.service`
|
||||
|
||||
```
|
||||
[Unit]
|
||||
Description=OnlyOffice Server
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
WorkingDirectory=/python/onlyoffice-cloudreve/
|
||||
ExecStart=/usr/bin/python3 -m sanic main:app --host=0.0.0.0 --port=8000
|
||||
Restart=always
|
||||
TimeoutSec=0
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
```
|
||||
#### 启动服务并设置开机自启
|
||||
```
|
||||
systemctl daemon-reload
|
||||
systemctl start onlyoffice
|
||||
systemctl enable onlyoffice
|
||||
```
|
||||
### 查看服务状态
|
||||
`systemctl status onlyoffice`
|
22
main.py
22
main.py
|
@ -16,7 +16,11 @@ CORS(app)
|
|||
@app.route("/")
|
||||
@app.route("/index.html")
|
||||
def index(request):
|
||||
return render_template("index.html", scheme=request.headers["X-Scheme"])
|
||||
try:
|
||||
scheme = request.headers["X-Scheme"]
|
||||
except:
|
||||
scheme = request.scheme
|
||||
return render_template("index.html", scheme=scheme)
|
||||
|
||||
|
||||
@app.route("/favicon.ico")
|
||||
|
@ -24,9 +28,12 @@ def favicon(request):
|
|||
return file("./favicon.ico")
|
||||
|
||||
|
||||
@app.route("/<name:([a-z]{4})\.html>", methods=["GET", "POST"])
|
||||
@app.route("/<name:([a-z]{4})\.html>", methods=["GET"])
|
||||
async def view(request, name):
|
||||
scheme = request.headers["X-Scheme"]
|
||||
try:
|
||||
scheme = request.headers["X-Scheme"]
|
||||
except:
|
||||
scheme = request.scheme
|
||||
url = request.args.get("src")
|
||||
if not url:
|
||||
return render_template("index.html", scheme=scheme)
|
||||
|
@ -35,9 +42,10 @@ async def view(request, name):
|
|||
return render_template("msg.html", msg=msg)
|
||||
url = unquote(url)
|
||||
suffix = url.split(".")[-1]
|
||||
suffixs = ["", "docx", "pptx", "docm", "xlsx", "xlsm", "xltx", "xltm", "xlsb", "xlam", "pptm",
|
||||
"ppsx", "ppsm", "rtf", "mdb", "pdf"]
|
||||
if suffix not in suffixs:
|
||||
suffixs = ["docx", "doc", "pptx", "ppt", "docm", "xlsx", "xls", "xlsm", "xltx", "xltm", "xlsb", "xlam", "pptm",
|
||||
"ppsx", "ppsm", "rtf", "mdb", "pdf", "wps", "et", "dps", "csv", "odp", "odt", "ods", "docxf", "epub",
|
||||
"fb2", "html", "oform", "ott", "txt", "xml", "xps"]
|
||||
if suffix.lower() not in suffixs:
|
||||
try:
|
||||
resp = get(url)
|
||||
except:
|
||||
|
@ -62,6 +70,4 @@ async def view(request, name):
|
|||
|
||||
return render_template(f"{name}.html", host=host, suffix=suffix, filename=filename, url=url)
|
||||
|
||||
|
||||
|
||||
# app.run(host='127.0.0.1', port=8000, debug=False, auto_reload=True)
|
||||
|
|
Loading…
Reference in New Issue