简单图像上传程序

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 Spring引导,通过POST从InputStream上载文件期间RestTemplate异常   Java小程序在小程序查看器中运行,但不在浏览器中运行   swing如何追踪Java中看似随机的崩溃?   带线程池的多线程Java阶乘计算   java EWS:FindItem请求异常中不支持的限制   java Android studio ListView默认项   Java的字符串。split()删除尾随的空条目   java如何在j2EE应用程序中通过JMS和Websphere MQ发送和接收xml文件   facebook图形api Solrjava错误:class com。restfb。类型。Post声明多个名为type的JSON字段   java Oracle数据库:使用字符(X)或数字(X)代替日期   java如何在saxon中使用DirectoryCollection   oracle我可以脱机“查看”Java标准库吗   java的增量if循环函数在主函数的增量循环中   oracle数字类型的数据库java映射   java读取一个文本文件并写入多个文本文件以进行过滤/提取   java ImageJ无法获取CurrentImage