简单图像上传程序

imgtohttps的Python项目详细描述


关于

通过url将所有不安全的图像上载到imgur的微服务。

使用redis作为缓存后端和元数据存储。

安装

安装uwsgi和python3插件:

sudo apt-get install uwsgi uwsgi-plugin-python3

制作virtualenv:

cd /opt
pyvenv-3.4 img_service
source img_service/bin/activate

从pypi安装:

pip install imgtohttps

为应用程序创建配置文件:

[uwsgi]
plugins = python34
master = true
enable-threads = true
processes = 4
module = imgtohttps.application:app
virtualenv = /opt/img_service
chdir = /opt/img_service
touch-reload = /opt/img_service/reload
env=APP_SETTINGS=settings.Production

连接到nginx:

server {
    listen          127.0.0.1:2100;
    access_log off;
    location / {
        uwsgi_pass  unix:/run/uwsgi/app/img_service/socket;
        include             uwsgi_params;
    }
}

用法

请求:

curl -X POST -H "Content-Type: application/json" -d '{"url": "http://example.com/image.png"}' http://localhost:2100

响应:

{"url": "https://i.imgur.com/AxQwu0h.png"}

错误:

{"error": "Some error message"}

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java根据两个数组的值对数组进行排序   具有自签名证书和NTLM代理的java Maven SSL repo错误   java自定义字体按钮不工作AndroidStudio   java通过Spring MVC web应用程序向客户端发送文本文件   Java Spring Web服务SOAP身份验证   ANT property environment=“env”无法在JAVA中检索它,但如果作为ANT命令运行,则可以正常工作   java是为spring mvc rest api或spring boot api对应用服务器的每个新请求创建的服务、存储库和组件的新实例吗?   java私有静态最终字符串未完成其工作   PKCS12的安全Java密钥重新处理   java JPA继承表每类SQLSyntaxErrorException