GithubHelp home page GithubHelp logo

yyjeffrey / july_server Goto Github PK

View Code? Open in Web Editor NEW
19.0 1.0 10.0 64 KB

WeChat Mina for Social Platform by Flask - 七月社交小程序-服务端

License: Apache License 2.0

Dockerfile 0.37% Python 77.17% PLpgSQL 22.46%

july_server's Introduction

july_server

build build

七月微信小程序——服务端

客户端请见 https://github.com/YYJeffrey/july_client

技术交流(闲聊吹水)群:592832957,请备注来源,谢谢!

项目结构

  • /app 应用包
    • /api 接口包
    • /config 配置包
    • /lib 工具包
    • /manger 第三方包
    • /model 模型包
    • /patch 增强包
    • /service 业务包
    • /validator 校验包
  • /log 日志目录
  • /sql 数据库文件
  • .env_template 环境变量模板
  • gconfig.py gunicorn配置
  • starter.py 启动文件

开发使用

1. 开发环境

  • Python 3.7.9
  • MySQL 5.7.28

2. 安装依赖

方式一(推荐):使用 pipenv 安装依赖

pipenv install

方式二:使用 pip 安装依赖

pip install -r requirements.txt

3. 配置环境变量

  • 方式一(推荐):配置 .env_templaet 文件,修改所有 xxx 的环境变量,比将文件重命名为 .env
  • 方式二:直接 config/base.py 修改对应配置

4. 用到的第三方服务

5. 导入数据库文件

创建一个名为 july 的数据库,字符集 utf8mb4,排序规则 utf8mb4_general_ci,之后将 sql/july.sql 导入到该数据库中即可

6. 修改数据库模型

若需要修改数据库模型,在 model 模型包中修改对应模型的字段后,执行下方命令。需要注意,必须配置好环境变量才可运行

# 初始化数据库
flask db init

# 生成迁移脚本
flask db migrate

# 更新数据库模型
flask db upgrade

7. 运行

python starter.py

8. 导出依赖(无需执行)

pipenv run pip freeze > requirements.txt

生产使用

在此之前,请按照开发使用的第3步修改环境变量

方式一(推荐):Docker启动

# 构建 Dockerfile
docker build -t july-server .

# 运行
docker run -d -p 5000:5000 -v $(pwd):/root/july-server --env-file .env --name july-server july-server

方式二:直接启动

# 运行
gunicorn -w 1 -b 0.0.0.0:5000 starter:app --worker-class eventlet --reload

# 停止
ps aux | grep gunicorn | awk '{print $2}' | xargs kill -9

捐赠

如果觉得还不错,就支持一下作者吧 😊

赞赏码

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.