├── .dockerignore ├── .gitignore ├── .travis.yml ├── Dockerfile ├── FAQ.md ├── LICENSE ├── README.md ├── VERSION.md ├── aapt_centos ├── aapt_mac ├── app ├── __init__.py ├── blueprints │ ├── __init__.py │ ├── app_versions.py │ ├── apps.py │ ├── exception.py │ ├── short_chain.py │ ├── static.py │ └── upload.py ├── config │ ├── __init__.py │ └── config.py ├── db │ ├── __init__.py │ └── models │ │ ├── __init__.py │ │ ├── app.py │ │ └── app_version.py ├── exceptions │ └── __init__.py ├── log.py └── utils │ ├── __init__.py │ ├── alchemy_json_encoder.py │ ├── byte.py │ ├── date.py │ ├── db.py │ ├── ipa_plist.py │ ├── json_result.py │ ├── package_parse.py │ └── regex.py ├── generate_certificate.sh ├── html ├── favicon.ico ├── index.css ├── index.html └── index.js ├── img ├── 1.png ├── 2.png ├── alipay.png ├── app_detail.png ├── app_edit.png ├── home.png ├── iPhone_1.png ├── iPhone_2.png ├── iPhone_3.png ├── iphone_4.png ├── iphone_5.PNG ├── qq.png ├── upload.png └── wx.png ├── main.py ├── requirements.txt ├── requirements_test.txt ├── tests ├── QXmokuai_3.apk ├── __init__.py ├── test_app.py ├── test_apps.py ├── test_html.py └── tests.py └── vendors └── pngdefry ├── miniz.c └── pngdefry.c /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | *.md 3 | LICENSE 4 | .* 5 | data 6 | img 7 | log 8 | __pycache__/ 9 | .idea 10 | Dockerfile -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | 27 | # PyInstaller 28 | # Usually these files are written by a python script from a template 29 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 30 | *.manifest 31 | *.spec 32 | 33 | # Installer logs 34 | pip-log.txt 35 | pip-delete-this-directory.txt 36 | 37 | # Unit test / coverage reports 38 | htmlcov/ 39 | .tox/ 40 | .coverage 41 | .coverage.* 42 | .cache 43 | nosetests.xml 44 | coverage.xml 45 | *,cover 46 | .hypothesis/ 47 | 48 | # Translations 49 | *.mo 50 | *.pot 51 | 52 | # Django stuff: 53 | *.log 54 | local_settings.py 55 | 56 | # Flask stuff: 57 | instance/ 58 | .webassets-cache 59 | 60 | # Scrapy stuff: 61 | .scrapy 62 | 63 | # Sphinx documentation 64 | docs/_build/ 65 | 66 | # PyBuilder 67 | target/ 68 | 69 | # IPython Notebook 70 | .ipynb_checkpoints 71 | 72 | # pyenv 73 | .python-version 74 | 75 | # celery beat schedule file 76 | celerybeat-schedule 77 | 78 | # dotenv 79 | .env 80 | 81 | # virtualenv 82 | venv/ 83 | ENV/ 84 | 85 | # Spyder project settings 86 | .spyderproject 87 | 88 | # Rope project settings 89 | .ropeproject 90 | 91 | # idea 92 | .idea 93 | 94 | # project 95 | data 96 | test 97 | pngdefry 98 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - "3.5" 4 | - "3.6" 5 | # command to install dependencies 6 | install: "pip install -r requirements_test.txt" 7 | # command to run tests 8 | script: pytest -q tests 9 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | ############################################################ 2 | # Build a AppServer container images 3 | # 不修改 app/config/config.py:BaseConfig.host , 会导致iOS无法在线下载安装ipa 4 | # 使用: 5 | # 1. docker build -t app_server ./ 6 | # 2. docker run -d -p 8000:8000 -v /path/to/data:/www/AppServer/data -v /path/to/log:/www/AppServer/log --name AppServer app_server 7 | # or 8 | # docker run -d -p 8000:8000 --name AppServer app_server 9 | ############################################################ 10 | 11 | FROM centos:latest 12 | 13 | MAINTAINER skytoup 875766917@qq.com 14 | 15 | RUN yum -y install zlib* sqlite-devel gcc make python-setuptools openssl openssl-devel libpng12 16 | 17 | # install python3.6.1 18 | RUN curl -O https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz \ 19 | && tar -zxvf Python-3.6.1.tgz && cd Python-3.6.1 \ 20 | && ./configure --with-ssl --enable-loadable-sqlite-extensions \ 21 | && make \ 22 | && make install \ 23 | && cd .. \ 24 | && rm -rf Python-3.6.1* 25 | 26 | RUN mkdir -p /www/AppServer 27 | COPY ./ /www/AppServer 28 | 29 | WORKDIR /www/AppServer 30 | RUN gcc vendors/pngdefry/pngdefry.c -o pngdefry 31 | RUN mkdir data log 32 | RUN python3 -m pip install -i https://pypi.douban.com/simple/ -r requirements.txt 33 | 34 | VOLUME ["data", "log"] 35 | EXPOSE 8000 36 | 37 | CMD ["python3", "main.py"] 38 | -------------------------------------------------------------------------------- /FAQ.md: -------------------------------------------------------------------------------- 1 | # FAQ 2 | ## 开启服务器后, 在浏览器为什么访问不了AppServer的网页 3 | 1. 检查服务器是否开启成功 4 | 2. 检查html文件夹内是否存在index.html文件, 不存在请重新生成, 传送门: [AppServerHTML](https://github.com/skytoup/AppServerHTML) 5 | 6 | ## iPhone无法安装App 7 | 1. 开启服务器后, 需要在地址栏输入的是**Config的host**, 不能填写127.0.0.1、localhost、0.0.0.0(会导致无法安装); 还有协议是`https`, 不是`http` 8 | 2. `iPhone`安装ipa需要在App详情的界面里面点击安装证书, 因为证书是自己生成的, 不能免证书安装(**iOS9以上系统安装完证书后, 还需要在设置那里信任一下证书**, 请参考: [苹果iOS9系统安装应用证书信任操作指导](http://jingyan.baidu.com/article/9c69d48f98e11813c8024e77.html)) 9 | ![img](img/iphone_1.png) 10 | ![img](img/iphone_2.png) 11 | ![img](img/iphone_3.png) 12 | ![img](img/iphone_4.png) 13 | ![img](img/iphone_5.png) 14 | 3. 检查`iPhone`上安装的证书是不是旧的, 可以删除之后再安装一次 15 | 4. `ipa`的安装包只能是是ad证书所打包出来的(企业证书也可以?没有, 没法证实, 知道的可以告诉我一下😄) 16 | 17 | ## Linux上传apk一直失败 18 | 1. 检测日志, 如果报错如下 19 | 20 | ``` 21 | ./aapt_centos: error while loading shared libraries: libpng12.so.0: cannot open shared object file: No such file or directory 22 | ``` 23 | 24 | 请安装`libpng12`的库: 25 | 26 | - centos: `yun install libpng12` 27 | - 其它待测试... -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 skytoup 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AppServer 2 | 3 | ![license](https://img.shields.io/badge/license-MIT-blue.svg) 4 | 5 | ## 简介 6 | 基于`Sanic`搭建的简单`App`在线下载、安装服务器。可在线下载安装包, 或者`iPhone`在线安装ipa。 7 | 8 | **首页** 9 | ![pic](img/home.png) 10 | 11 | **上传App** 12 | ![pic](img/upload.png) 13 | 14 | **App详情页** 15 | ![pic](img/app_detail.png) 16 | 17 | **App编辑页** 18 | ![pic](img/app_edit.png) 19 | 20 | ## 功能 21 | - [x] `RESTful`的API 22 | - [x] 上传apk、ipa文件 23 | - [x] 下载apk、下载ipa 24 | - [x] 短链接进入下载页 25 | - [x] App、版本管理 26 | - [x] 搜索App 27 | - [ ] HTML更好兼容移动端 28 | 29 | 更多... 30 | 31 | ## 使用 32 | ### 环境 33 | - Python > 3.5 34 | - macOS 10.12+ 35 | - centos 6+ 36 | - ubuntu 14.04+ 37 | - 还有其它更多尚未测试... 38 | 39 | ### 配置(app/config.py) 40 | 把`Config`的`host`修改为本机地址 41 | ![配置](img/1.png) 42 | 43 | ### 运行服务器 44 | 45 | #### 源码运行 46 | # linux系统请注意, 需要安装libpng12(centos已测试, 其它系统还没测试), MacOSX系统不需要 47 | `yum install libpng12` # centos 48 | 49 | 1. `git clone https://github.com/skytoup/AppServer` 50 | 2. `cd AppServer` 51 | 3. `gcc vendors/pngdefry/pngdefry.c -o pngdefry # 编译pngdfry` 52 | 4. `pip install -r requirements.txt # 安装依赖` 53 | 5. `python main.py # 运行服务器` 54 | ![运行](img/2.png) 55 | 6. `open https://your_bing_host:8000` # or 打开浏览器, 输入https://{Config的host}:8000, 回车 56 | 57 | #### Docker运行 58 | 1. `git clone https://github.com/skytoup/AppServer` 59 | 2. `cd AppServer` 60 | 3. 修改`app/config/config.py:BaseConfig.host`为需要绑定的ip地址, 设置错误会导致iOS无法在线下载安装ipa 61 | 4. `docker build -t app_server ./` 62 | 5. `docker run -d -p 8000:8000 -v /path/to/data:/www/AppServer/data -v /path/to/log:/www/AppServer/log --name AppServer app_server` # or 63 | `docker run -d -p 8000:8000 --name AppServer app_server` 64 | 6. `open https://your_bing_host:8000` # or 打开浏览器, 输入https://{Config的host}:8000, 回车 65 | 66 | 67 | ### 服务器的单元测试 68 | 1. `pip install -r requirements_test.txt` 69 | 2. `pytest -q tests` 70 | 71 | ### HTML前端 72 | 不是专业前端, 只是简单做了一个非常简陋的, 请勿介意😅 73 | 74 | 详情请看 👉 传送门: [AppServerHTML](https://github.com/skytoup/AppServerHTML) 75 | 76 | ### https证书 77 | 证书使用的是自签证书, 每次修改`Config`的`host`后, 会自动重新生成 78 | 79 | ### Tip 80 | 1. 开启服务器后, 需要在地址栏输入的是**Config的host**, 不能填写127.0.0.1、localhost、0.0.0.0; 还有协议是`https`, 不是`http` 81 | 2. `iPhone`安装ipa需要在App详情的界面里面点击安装证书, 因为证书是自己生成的, 不能免证书安装(**iOS9以上系统安装完证书后, 还需要在设置那里信任一下证书**, 请参考: [苹果iOS9系统安装应用证书信任操作指导](http://jingyan.baidu.com/article/9c69d48f98e11813c8024e77.html)) 82 | 3. `centos`和`ubuntu`安装可能出现的问题 👉 [传送门](https://github.com/skytoup/AppServer/issues/1) 83 | 4. `linux`运行`aapt`需要安装`libpng12`, centos: `yum install libpng12` 84 | 85 | 更详细请看 👉 [FAQ](FAQ.md) 86 | 87 | ## API 88 | ### 基本格式 89 | ``` 90 | { 91 | code: int, # 请参考👇的表 92 | ok: bool, # 是否请求成功 93 | msg: str, # 请求返回的信息 94 | datas: dict/array, # 请求返回的数据 95 | } 96 | ``` 97 | 98 | | code | 描述 | 99 | | --- | --- | 100 | | 0 | 成功 | 101 | | -1 | 失败 | 102 | 103 | ### 上传App安装包 104 | POST /upload/app 105 | > Form 106 | 107 | | 参数 | 必填 | 描述 | 108 | |---|:-:|---| 109 | | pcakage | y | 上传的安装包 | 110 | | msg | n | 更新说明 | 111 | 112 | > 返回datas: object or not(上传不存在的App时, 才有返回) 113 | 114 | | 参数 | 描述 | 115 | | --- | --- | 116 | | id | App的id | 117 | | type | 安装包类型, 0: iOS, 1: Android | 118 | | name | 名称 | 119 | | icon | 图标 | 120 | | detail | 介绍 | 121 | | short_chain | 短链接 | 122 | | package_name | 包名 | 123 | | create_at | 创建时间 | 124 | 125 | ### 获取App列表 126 | GET /apps//page/?t=