1 Star 2 Fork 1

不问江湖任少侠/showdoc-upload

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
ShowdocInteractionWithServer.py 5.35 KB
一键复制 编辑 原始数据 按行查看 历史
#-*-coding:utf8 -*-
import requests
import os
import time
import json
import ShowdocCfg
host = '192.168.0.103';
port = '4999';
username = 'showdoc';
password = '123456';
server = 'http://%s:%s//server/index.php' %(host,port);
querys ={
'login':'s=/api/user/login', #可以用来登录
'item_list':'s=/api/item/myList', #可以获取到主页上所有的文档项目
'item_info':'s=/api/item/info', #可以获取某个项目下面的所有的文件夹列表
'page_info':'s=/api/page/info', #获取某个界面的内容,这个暂时不用。
'get_key':'s=/api/item/getKey', #可以获取当前key和令牌
'update':'s=/api/item/updateByApi', #上传文档。
'upload_img':'s=/api/page/uploadImg',#上传图片,不过后面要加上guid=计算的ms时间
'set_lock':'s=/api/page/setLock',#模拟编辑界面的时候,要先对这个界面上锁
'is_lock':'s=/api/page/isLock',#模拟发送is_lock
'get_page_by_cat':'s=/api/catalog/getPagesBycat',#模拟上锁之后,进入这个界面。
'cat_list_group':'s=/api/catalog/catListGroup',#模拟进入摸个界面前,先获取group
'check_db':'s=/api/update/checkDb',#模拟检查 数据库
'user_info':'s=/api/user/info',
};
def showdoc_update_cfg():
global host;
global port;
global username;
global password;
global server;
host = ShowdocCfg.get_cfg_host();
port = ShowdocCfg.get_cfg_port();
username = ShowdocCfg.get_cfg_user_name();
password = ShowdocCfg.get_cfg_password();
server = 'http://%s:%s/server/index.php' %(host,port);
def showdoc_login():
showdoc_update_cfg();
session = requests.session();
login_url = server + '?' + querys['login'];
login_data = {'username':username,'password':password};
response = session.post(login_url,data=login_data,allow_redirects=False);
return session,response.text.encode('utf-8').decode("unicode_escape");
def showdoc_get_item_list(session):
get_item_list_url = server + '?' + querys['item_list'];
get_list_data = {'item_group_id':'0'};
response = session.post(get_item_list_url,data=get_list_data,allow_redirects=False);
return response.text.encode('utf-8').decode("unicode_escape");
def showdoc_get_item_info(session,item_id):
item_id_data = {'item_id':item_id};
get_item_info_url = server + '?' + querys['item_info'];
response = session.post(get_item_info_url,data=item_id_data,allow_redirects=False);
return response.text.encode('utf-8').decode("unicode_escape");
def showdoc_get_item_key(session,item_id):
item_id_data = {'item_id':item_id};
get_item_info_url = server + '?' + querys['get_key'];
response = session.post(get_item_info_url,data=item_id_data,allow_redirects=False);
return response.text.encode('utf-8').decode("unicode_escape");
def showdoc_upload_file(api_key,api_token,page_title,page_content,cat_name):
upload_file_url = server + '?' + querys['update'];
upload_data = {'api_key':api_key,'api_token':api_token,'page_title':page_title,'page_content':page_content,'cat_name':cat_name};
response = requests.post(upload_file_url,data=upload_data);
return response.text.encode('utf-8').decode("unicode_escape");
def showdoc_upload_image(session,image_path,guid):
dir,file = os.path.split(image_path);
upload_img_url = server + '?' + querys['upload_img'] + '&guid=' + guid;
files = {
"editormd-image-file":(file,open(image_path,'rb'),"image/png",{ "Content-Disposition": "form-data"}),
}
data = {};
response = session.post(upload_img_url,data=data,files=files,allow_redirects=False);
return response.text.encode('utf-8').decode("unicode_escape");
def showdoc_get_page_info(session,page_id):
page_id_data = {'page_id':page_id};
get_page_info_url = server + '?' + querys['page_info'];
response = session.post(get_page_info_url,data=page_id_data,allow_redirects=False);
return response.text.encode('utf-8').decode("unicode_escape");
def showdoc_is_lock(session,page_id):
is_lock_data = {'page_id':page_id};
is_lock_url = server+'?'+querys['is_lock'];
response = session.post(is_lock_url,data=is_lock_data,allow_redirects=False);
return response.text.encode('utf-8').decode("unicode_escape");
def showdoc_set_lock_page(session,item_id,page_id,lock_type):
lock_data = {'item_id':item_id,'page_id':page_id};
set_lock_url = server+'?'+querys['set_lock'];
response = session.post(set_lock_url,data=lock_data,allow_redirects=False);
return response.text.encode('utf-8').decode("unicode_escape");
def showdoc_get_page_by_cat(session,item_id,cat_id):
data = {'cat_id':cat_id,'item_id':item_id};
url = server +'?' + querys['get_page_by_cat'];
response = session.post(url,data=data,allow_redirects=False);
return response.text.encode('utf-8').decode("unicode_escape");
def showdoc_cat_list_group(session,item_id):
data = {'item_id':item_id};
url = server +'?' + querys['cat_list_group'];
response = session.post(url,data=data,allow_redirects=False);
return response.text.encode('utf-8').decode("unicode_escape");
def showdoc_check_db(session):
url = server + '?' + querys['check_db'];
response = session.get(url,allow_redirects=False);
return response.text.encode('utf-8').decode("unicode_escape");
def showdoc_get_user_info(session):
get_user_info_url = server + '?' + querys['user_info'];
response = session.post(get_user_info_url,data={},allow_redirects=False);
return response.text.encode('utf-8').decode("unicode_escape");
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/renyongjian/showdoc-upload.git
[email protected]:renyongjian/showdoc-upload.git
renyongjian
showdoc-upload
showdoc-upload
master

搜索帮助