npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

picgo-plugin-easypic

v1.0.2

Published

An uploader for My-Easy-Pic-Bed.

Downloads

31

Readme

picgo-plugin-easypic

简介

My-Easy-Pic-Bed 为国内开发者 fslongjin 创建的开源、便捷、高效的图床服务,您可以将该服务部署在 云服务器个人主机NAS 等设备上,之后您便可以将图片上传至相应的服务器并获取图片链接。

环境搭建

下面我将演示如何在 本地主机 上搭建环境,若您要在 云服务器其它环境 上搭建,这些操作也同样适用。

  1. 前往 My-Easy-Pic-Bed 下载图床服务

    image-20220210201146087

  2. 将压缩包解压后放在你的服务器中,解压后文件如图

    image-20220210201042704

  3. 可在config.ini中设置端口号和图片最大尺寸限制

    [strings]
    running_domain = 0.0.0.0	
       
       
    [ints]
    max_length = 10		// 最大尺寸为10M
    port = 9999			// 端口号为9999
  4. 为正常使用该插件请修改 app.py 代码,具体参见 图片链接无法访问

    import os
    from flask import Flask, flash, request, redirect, url_for, render_template, current_app
    from werkzeug.utils import secure_filename
    from flask import send_from_directory
    import random, time
    import db
    import getConfig as gcf
       
    from flask.cli import with_appcontext
       
    cf = gcf.get_config()
       
    allowed_extensions = {'txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'}
    upload_folder = os.path.join(os.getcwd(), 'pics')
    print(upload_folder)
    app = Flask(__name__, instance_relative_config=True)
       
       
    def allowed_file(filename):
        return '.' in filename and filename.rsplit('.', 1)[1].lower() in allowed_extensions
       
       
    @app.route('/', methods=['POST', 'GET'] )
    def upload_file():
        if request.method == 'POST':
            # 检查post请求中是否有文件
            if 'file' not in request.files:
                flash('你没有上传文件!')
                return redirect(request.url)
            file = request.files['file']
            print(file)
            if file.filename == '':
                flash('你没有选择文件!')
                return redirect(request.url)
            if file and allowed_file(file.filename):
                filename = file.filename
                try:
                    file.save(os.path.join(upload_folder, filename))
                    database = db.get_db()
                    database.execute(
                        'INSERT INTO pics (filename)'
                        ' VALUES (?)',
                        (filename,)
                    )
                    database.commit()
                    if app.config['running_port'] != 80:
                        flash(app.config['running_domain'] + ':' + str(app.config['running_port']) + url_for('uploaded_file', filename=filename))
                    else:
                        flash(app.config['running_domain'] + url_for('uploaded_file', filename=filename))
                except Exception as e:
                    flash('出现错误!')
                    print(e.args)
       
                return redirect(url_for('upload_file'))
            else:
                flash('不被服务器支持的文件!')
                return redirect(url_for('upload_file'))
        database = db.get_db()
        pcnum = database.execute("SELECT Count(*) FROM pics").fetchone()[0]
        print(pcnum)
       
        return render_template('bs_index.html', pic_num=pcnum)
       
       
    @app.route('/uploads/<filename>')
    def uploaded_file(filename):
        return send_from_directory(app.config['UPLOAD_FOLDER'], filename)
       
       
    if __name__ == '__main__':
       
        app.config['UPLOAD_FOLDER'] = upload_folder
        app.config['running_domain'] = cf['running_domain']
        app.config['running_port'] = cf['port']
        app.config['MAX_CONTENT_LENGTH'] = 1024 * 1024 * int(cf['max_length'])
        app.config.from_mapping(
            SECRET_KEY='dgvbv43@$ewedc',
            DATABASE=os.path.join(app.instance_path, 'my-easy-pic-bed.sqlite'),
        )
        # ensure the instance folder exists
        try:
            os.makedirs(app.instance_path)
        except OSError:
            pass
       
        try:
            os.mkdir(upload_folder)
        except Exception as e:
            pass
       
        app.run(debug=False, host=app.config['running_domain'], port=app.config['running_port'])
  5. 双击 startProgram.exe 启动图床服务

    image-20220210182759058

    image-20220210194816559

  6. GUI 搜索下载 easypic

    image-20220210194913624

  7. 根据实际修改相关设置

    image-20220210195011555

    • 服务器IP:部署图床服务的服务器IP,若部署在本机则为127.0.0.1
    • 端口号:config.ini中设置的端口号,默认80
  8. 点击确定,设置完成!

Q & A

1.如何查看本机IP?

  1. 键盘按下win + r,输入cmd

    image-20220210195431387

  2. 输入ipconfig,回车

    image-20220210195552474

  3. Ipv4地址即为服务器IP地址

2.图片的具体存储位置?

所有图片均存储于 解压根目录/pics

3.其它上传方式?

  1. 浏览器输入http://{ip}:{port}

image-20220210195952690

  1. 选择要上传的文件后点击开始上传即可

4.如何在运行图床服务时不显示终端?

在压缩包根目录下有两个批处理命令 start.batstop.bat,双击 start.bat 即可运行图床服务而不弹出终端,双击 stop.bat 即可关闭图床服务。