Giter Club home page Giter Club logo

mini-status's Introduction

mini-status

中文 | English

微信小程序miniStatus的后端程序

介绍

miniStatus是一个美观可定制主题的服务器监控小程序,可实现小程序与服务器的点对点连接,展示服务器基本运行状态,这个项目是其对应的后端程序。

特点

  • 直接通过小程序和服务器的点对点连接,数据不经过第三方中转
  • 不要求服务器域名备案,可以直接使用ip,甚至局域网地址

miniStatus小程序

小程序地址

搜索miniStatus小程序

节点列表界面

自定义主题样式界面

安装

npm install mini-status -g

使用

命令行参数

usage: mini-status [-h] [-v] [-u URI] [-a ADDRESS] [-p PASSWORD]

miniStatus backend program

Optional arguments:
  -h, --help            Show this help message and exit.
  -v, --version         Show program's version number and exit.
  -u URI, --uri URI     uri for api, default '/update'
  -a ADDRESS, --address ADDRESS
                        address to listen, default 0.0.0.0:8080
  -p PASSWORD, --password PASSWORD
                        access password, default 1234567890

配置微信小程序

点击小程序右下角的+按钮,填写对应的配置选项

例如,mini-status -a A.B.C.D:8080 -u /status -p 123 对应的信息为:

接口地址:http://A.B.C.D:8080/status

password: 123

节点名用于标识该节点,可以随便填写

原理

这是一个黑魔法(hhh开玩笑

原理很简单,是巧妙运用了小程序image组件的bindload接口,当图片加载成功时会返回图片的宽和高。也就是说一个图片能够返回两个数值,前后端约定好请求API后可以动态创建image获取一系列数值。

注意这个接口是不要求图片地址是备案域名,不用在小程序开发信息中报备。但是这种信息传递方式比较低下,只适合传递少量的信息。所以拿来做了这个点对点的服务器监控小程序。

但是直接传递大体积的二进制图片很浪费带宽,解决方案是后端动态生成svg图片。也就是说,动态返回下面这种形式的文字信息:

<svg width="${width}" height="${height}" xmlns="http://www.w3.org/2000/svg"></svg>

详细的实现可以看这个文件

FAQ

mini-status's People

Contributors

axipo avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.