8

基于python tornado实现的简易图床 - Free_A

 2 years ago
source link: https://www.cnblogs.com/Free-A/p/17614402.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

基于python tornado实现的简易图床

项目地址

因为买了阿里/腾讯的云服务器,但是使用云存储还需要收费,又加上家里正好有一台nas,又加上闲的没事,所以搞了一个小脚本

这个项目主要功能是为typora增加一个自定义图床

欢迎提出issues和pr,如果闲的没事会考虑增加一个web界面来上传图片

环境为:python3.10+

conf.ini参数解释:

base_url:server部署的地址,默认为本机32251端口
secret_key:server端与客户端定义的密钥

本地运行首先执行:

pip install -r requirements.txt

docker运行示例:

docker run --name pyimgs -e PORT=端口 -e SECRET_KEY=密钥 -v 本地路径:/pyimgs/server/upload -p 本地端口:容器端口 -d freenn/pyimgs:1.2

命令行启动服务端示例:

python server/main.py --port=端口 --secret_key=密钥

客户端启动示例:

首先运行一遍下面的命令,带不带参数都可以

python client/app.py <参数一>图片地址  <参数二>图片地址 ...

然后生成了conf.ini配置文件,修改配置文件中的base_urlsecret_key与服务端一致

  • 备注1:conf.ini中的value不需要加引号

  • 备注2:也可以在这里下载客户端exe

运行方式为,先双击exe文件,生成log文件夹和conf.ini默认配置,然后将图片拖动到exe文件上即可上传文件

typora配合使用:

具体使用方法如下

  • ctrl+逗号打开偏好设置

  • 点击图像并且将配置改为图片相同的设置

    6dbbf04635b111ee84090242ac110009.png
  • 将上传服务改为Custom Command,将命令改为app.exe所在位置

    e929ecce35b111ee84090242ac110009.png
  • 点击验证图片上传选项

    提示成功说明上传成功

    6743d61a35b211ee84090242ac110009.png

    如果失败则查看日志并且提交到issues


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK