From acff3a6cc6c323b08cc5e59922c61357ff7df031 Mon Sep 17 00:00:00 2001 From: Ang Long Date: Wed, 17 May 2017 15:31:59 +0800 Subject: [PATCH 01/38] feat: add https redirect middleware codes (#15) --- cloud.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cloud.py b/cloud.py index 3d0a506..694b75b 100644 --- a/cloud.py +++ b/cloud.py @@ -1,11 +1,14 @@ # coding: utf-8 +from leancloud import HttpsRedirectMiddleware from leancloud import Engine from leancloud import LeanEngineError from app import app +# 需要重定向到 HTTPS 可去除下一行的注释。 +# app = HttpsRedirectMiddleware(app) engine = Engine(app) From faf33dca42a43922879d59e0b949e5dc6d9ad7d1 Mon Sep 17 00:00:00 2001 From: Ang Long Date: Tue, 27 Jun 2017 14:17:56 +0800 Subject: [PATCH 02/38] feat: update to python-base environment (#16) --- .gitignore | 3 --- .python-version | 1 + runtime.txt | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) create mode 100644 .python-version delete mode 100644 runtime.txt diff --git a/.gitignore b/.gitignore index 39c39eb..82f10fb 100644 --- a/.gitignore +++ b/.gitignore @@ -70,9 +70,6 @@ target/ # IPython Notebook .ipynb_checkpoints -# pyenv -.python-version - # celery beat schedule file celerybeat-schedule diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..af9c448 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +2.7.11 diff --git a/runtime.txt b/runtime.txt deleted file mode 100644 index 16e8214..0000000 --- a/runtime.txt +++ /dev/null @@ -1 +0,0 @@ -python-2.7 From 2ea65dcab5c87faa3698e1aecfd1883e2a560889 Mon Sep 17 00:00:00 2001 From: Ang Long Date: Fri, 4 Aug 2017 14:28:53 +0800 Subject: [PATCH 03/38] feat: update leancloud sdk to 2.0.0 --- cloud.py | 8 +------- requirements.txt | 2 +- wsgi.py | 5 ++++- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/cloud.py b/cloud.py index 694b75b..18fecd2 100644 --- a/cloud.py +++ b/cloud.py @@ -1,15 +1,9 @@ # coding: utf-8 -from leancloud import HttpsRedirectMiddleware from leancloud import Engine from leancloud import LeanEngineError -from app import app - - -# 需要重定向到 HTTPS 可去除下一行的注释。 -# app = HttpsRedirectMiddleware(app) -engine = Engine(app) +engine = Engine() @engine.define diff --git a/requirements.txt b/requirements.txt index 6f5d2d7..c932c4c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ gevent>=1.0.2,<2.0.0 gevent-websocket>=0.9.5,<1.0.0 -leancloud-sdk>=1.0.9,<=2.0.0 +leancloud>=2.0.0,<3.0.0 Werkzeug>=0.11.11,<1.0.0 Flask>=0.10.1,<1.0.0 Flask-Sockets>=0.1,<1.0 diff --git a/wsgi.py b/wsgi.py index 78b4579..421428f 100644 --- a/wsgi.py +++ b/wsgi.py @@ -19,7 +19,10 @@ # 如果需要使用 master key 权限访问 LeanCLoud 服务,请将这里设置为 True leancloud.use_master_key(False) -application = engine +# 需要重定向到 HTTPS 可去除下一行的注释。 +# app = leancloud.HttpsRedirectMiddleware(app) +app = engine.wrap(app) +application = app if __name__ == '__main__': From 2a59daf95bd096005a68f98ee101f0cc160223af Mon Sep 17 00:00:00 2001 From: Ang Long Date: Thu, 17 Aug 2017 15:46:28 +0800 Subject: [PATCH 04/38] feat: update style --- static/style.css | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/static/style.css b/static/style.css index 6ce461d..d3f4169 100644 --- a/static/style.css +++ b/static/style.css @@ -1,4 +1,7 @@ -#container { - margin: 0 auto; - width: 960px; +body { + padding: 50px; + font: 14px "Lucida Grande", Helvetica, Arial, sans-serif; +} +a { + color: #00b7ff; } From 9885d3cd9645f78a80f98ef309c275a769b76310 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Sun, 30 Jul 2017 16:51:47 +0800 Subject: [PATCH 05/38] create pyup.io config file --- .pyup.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .pyup.yml diff --git a/.pyup.yml b/.pyup.yml new file mode 100644 index 0000000..a0833af --- /dev/null +++ b/.pyup.yml @@ -0,0 +1,4 @@ +# autogenerated pyup.io config file +# see https://pyup.io/docs/configuration/ for all available options + +schedule: every day From 92ae3f90aa63a37bafaa8cefbca97b902146aa81 Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Fri, 19 Apr 2019 18:14:25 +0800 Subject: [PATCH 06/38] =?UTF-8?q?feat:=20python=20=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E4=BB=8E=202=20=E5=8D=87=E7=BA=A7=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 从 2.7.11 升级至 3.7.3 原因: 1. Python 2 支持至今年底结束 2. 目前使用 Python 2.7.11 部署会报错 DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. Collecting undefined Could not find a version that satisfies the requirement undefined (from versions: ) No matching distribution found for undefined --- .python-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.python-version b/.python-version index af9c448..c1e43e6 100644 --- a/.python-version +++ b/.python-version @@ -1 +1 @@ -2.7.11 +3.7.3 From b854439a29b4424cec4009eb302ac434b252c5ab Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Mon, 22 Apr 2019 16:02:29 +0800 Subject: [PATCH 07/38] :alien: upgrade flask to 1.0 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index c932c4c..487d88f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,5 +2,5 @@ gevent>=1.0.2,<2.0.0 gevent-websocket>=0.9.5,<1.0.0 leancloud>=2.0.0,<3.0.0 Werkzeug>=0.11.11,<1.0.0 -Flask>=0.10.1,<1.0.0 +Flask>=1.0.0 Flask-Sockets>=0.1,<1.0 From 26ce3542977dee2e0aadd8a81bbe5312814ea0a2 Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Mon, 22 Apr 2019 16:16:12 +0800 Subject: [PATCH 08/38] =?UTF-8?q?:sparkles:=20REST=20API=20=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=20json=20=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 9 +++++++-- templates/index.html | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index aa7fdbf..bd475c8 100644 --- a/app.py +++ b/app.py @@ -1,8 +1,8 @@ # coding: utf-8 - +import sys from datetime import datetime -from flask import Flask +from flask import Flask, jsonify from flask import render_template from flask_sockets import Sockets @@ -30,3 +30,8 @@ def echo_socket(ws): while True: message = ws.receive() ws.send(message) + + +@app.route('/api/python-version', methods=['GET']) +def python_version(): + return jsonify({"python-version": sys.version}) \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index 0a2cbae..3d643a9 100644 --- a/templates/index.html +++ b/templates/index.html @@ -9,6 +9,7 @@

LeanEngine

这是 LeanEngine 的示例应用

一个简单的动态路由示例

+

REST API 返回 json 示例(当前运行的 python 版本)

一个简单的「TODO 列表」示例

From dd978aaaf7ee203615edce65d4b02cc19517c420 Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Mon, 22 Apr 2019 17:41:06 +0800 Subject: [PATCH 09/38] feat: REST API version of TODO sample --- app.py | 80 ++++++++++++++++++++++++++++++++++++++++++-- templates/todos.html | 7 ++++ 2 files changed, 85 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index bd475c8..03305a3 100644 --- a/app.py +++ b/app.py @@ -2,9 +2,11 @@ import sys from datetime import datetime -from flask import Flask, jsonify +import leancloud +from flask import Flask, jsonify, request from flask import render_template from flask_sockets import Sockets +from leancloud import LeanCloudError from views.todos import todos_view @@ -32,6 +34,80 @@ def echo_socket(ws): ws.send(message) +# REST API example +class BadGateway(Exception): + status_code = 502 + + def __init__(self, message, status_code=None, payload=None): + Exception.__init__(self) + self.message = message + if status_code is not None: + self.status_code = status_code + self.payload = payload + + def to_json(self): + rv = dict(self.payload or ()) + rv['message'] = self.message + return jsonify(rv) + + +class BadRequest(Exception): + status_code = 400 + + def __init__(self, message, status_code=None, payload=None): + Exception.__init__(self) + self.message = message + if status_code is not None: + self.status_code = status_code + self.payload = payload + + def to_json(self): + rv = dict(self.payload or ()) + rv['message'] = self.message + return jsonify(rv) + + +@app.errorhandler(BadGateway) +def handle_bad_gateway(error): + response = error.to_json() + response.status_code = error.status_code + return response + + +@app.errorhandler(BadRequest) +def handle_bad_request(error): + response = error.to_json() + response.status_code = error.status_code + return response + + @app.route('/api/python-version', methods=['GET']) def python_version(): - return jsonify({"python-version": sys.version}) \ No newline at end of file + return jsonify({"python-version": sys.version}) + + +@app.route('/api/todos', methods=['GET', 'POST']) +def todos(): + if request.method == 'GET': + try: + todo_list = leancloud.Query(leancloud.Object.extend('Todo')).descending('createdAt').find() + except LeanCloudError as e: + if e.code == 101: # 服务端对应的 Class 还没创建 + return jsonify([]) + else: + raise BadGateway(e.error, e.code) + else: + return jsonify([todo.dump() for todo in todo_list]) + elif request.method == 'POST': + try: + content = request.get_json()['content'] + except KeyError: + raise BadRequest('''receives malformed POST content (proper schema: '{"content": "TODO CONTENT"}')''') + todo = leancloud.Object.extend('Todo')() + todo.set('content', content) + try: + todo.save() + except LeanCloudError as e: + raise BadGateway(e.error, e.code) + else: + return jsonify(success=True) diff --git a/templates/todos.html b/templates/todos.html index 7df12b6..b4a2677 100644 --- a/templates/todos.html +++ b/templates/todos.html @@ -17,5 +17,12 @@

{{ title }}

{% endfor %} +
+

REST API

+
+        GET /api/todos
+        POST /api/todos {"content": "TODO CONTENT"}
+      
+
From 7df2fb660947fcd09e5de6fd1249902cb5e357e5 Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Tue, 25 Jun 2019 08:33:48 +0800 Subject: [PATCH 10/38] feat: print python version Inspect the python used by LeanEngine and local environment conveniently. related ticket: 20837 --- app.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app.py b/app.py index aa7fdbf..26a47fe 100644 --- a/app.py +++ b/app.py @@ -25,6 +25,12 @@ def time(): return str(datetime.now()) +@app.route('/version') +def print_version(): + import sys + return sys.version + + @sockets.route('/echo') def echo_socket(ws): while True: From ae89913def164e0db0cabb28821d19fd49c033f7 Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Thu, 24 Oct 2019 18:24:49 +0800 Subject: [PATCH 11/38] feat: require leancloud python sdk >= 2.2.0 python sdk 2.2.0 adds support for IM client online/offline hooks. --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 487d88f..679ab47 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ gevent>=1.0.2,<2.0.0 gevent-websocket>=0.9.5,<1.0.0 -leancloud>=2.0.0,<3.0.0 +leancloud>=2.2.0,<3.0.0 Werkzeug>=0.11.11,<1.0.0 Flask>=1.0.0 Flask-Sockets>=0.1,<1.0 From 3501fc81081e671a7ab7d21c09a4fd76da4e3950 Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Wed, 6 Nov 2019 17:26:38 +0800 Subject: [PATCH 12/38] fix: now deployable on LeanEngine Somehow LeanEngine Python 2 environment need to manually specify typing requirement. --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 487d88f..a1f719a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,4 @@ leancloud>=2.0.0,<3.0.0 Werkzeug>=0.11.11,<1.0.0 Flask>=1.0.0 Flask-Sockets>=0.1,<1.0 +typing From 24a0225b65fdb7fe12cf5857c640b28b3092fdc1 Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Wed, 6 Nov 2019 17:30:58 +0800 Subject: [PATCH 13/38] docs: update README --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 59addd7..5eea26d 100644 --- a/README.md +++ b/README.md @@ -28,11 +28,9 @@ pip install -r requirements.txt ### 关联应用: ``` -lean app add origin +lean switch ``` -这里的 appId 填上你在 LeanCloud 上创建的某一应用的 appId 即可。origin 则有点像 Git 里的 remote 名称。 - ### 启动项目: ``` From 63861d1f0ae116d223a28c2151d2308cd516f20c Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Tue, 10 Mar 2020 10:49:17 +0800 Subject: [PATCH 14/38] feat: upgrade python sdk version --- requirements.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 14ffc01..e565443 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,6 @@ gevent>=1.0.2,<2.0.0 gevent-websocket>=0.9.5,<1.0.0 -leancloud>=2.2.0,<3.0.0 -Werkzeug>=0.11.11,<1.0.0 +leancloud>=2.5.1,<3.0.0 Flask>=1.0.0 Flask-Sockets>=0.1,<1.0 typing From 44332529eb15f1b43ded8ed9bf167827038cb6ed Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Mon, 3 Aug 2020 17:43:49 +0800 Subject: [PATCH 15/38] docs: refine __main__ comment related forum post [23172] [23172]: https://forum.leancloud.cn/t/python-sdk-leancloud-sdk-must-be-initialized/23172 --- wsgi.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wsgi.py b/wsgi.py index 421428f..c12c8cf 100644 --- a/wsgi.py +++ b/wsgi.py @@ -24,9 +24,9 @@ app = engine.wrap(app) application = app - +# 以下代码只在本地开发环境执行 if __name__ == '__main__': - # 只在本地开发环境执行的代码 + from gevent.pywsgi import WSGIServer from geventwebsocket.handler import WebSocketHandler from werkzeug.serving import run_with_reloader From d3a9276737c21a9b2f7ab2133d80f09add451fd4 Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Thu, 6 Aug 2020 14:20:54 +0800 Subject: [PATCH 16/38] docs: update links in README --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5eea26d..a248a77 100644 --- a/README.md +++ b/README.md @@ -53,8 +53,9 @@ lean publish ## 相关文档 -* [LeanEngine 指南](https://leancloud.cn/docs/leanengine_guide.html) -* [Python SDK 指南](https://leancloud.cn/docs/python_guide.html) -* [Python SDK API](https://leancloud.cn/docs/api/python/index.html) -* [命令行工具详解](https://leancloud.cn/docs/cloud_code_commandline.html) -* [LeanEngine FAQ](https://leancloud.cn/docs/cloud_code_faq.html) +* [网站托管开发指南 · Python](https://leancloud.cn/docs/leanengine_webhosting_guide-python.html) +* [云函数开发指南 · Python](https://leancloud.cn/docs/leanengine_cloudfunction_guide-python.html) +* [数据存储开发指南 · Python](https://leancloud.cn/docs/leanstorage_guide-python.html) +* [Python SDK API](https://leancloud.github.io/python-sdk/) +* [LeanCloud 命令行工具详解](https://leancloud.cn/docs/leanengine_cli.html) +* [云引擎常见问题和解答](https://leancloud.cn/docs/leanengine_faq.html) From 861dcf87740d7f925a1354475ccf1fe885c68376 Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Thu, 6 Aug 2020 14:21:15 +0800 Subject: [PATCH 17/38] docs: typo & formatting in README --- README.md | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index a248a77..c28f3a7 100644 --- a/README.md +++ b/README.md @@ -5,13 +5,6 @@ ## 本地运行 -首先确认本机已经安装 [Python](http://python.org/) 运行环境。然后执行下列指令: - -## 一键部署 -[![Deploy to LeanEngine](http://ac-32vx10b9.clouddn.com/109bd02ee9f5875a.png)](https://leancloud.cn/1.1/functions/_ops/deploy-button) - -## 本地运行 - 首先确认本机已经安装 [Python](http://python.org/) 运行环境和 [LeanCloud 命令行工具](https://www.leancloud.cn/docs/leanengine_cli.html),然后执行下列指令: ``` @@ -19,19 +12,19 @@ $ git clone git@github.com:leancloud/python-getting-started.git $ cd python-getting-started ``` -### 安装依赖: +### 安装依赖 ``` pip install -r requirements.txt ``` -### 关联应用: +### 关联应用 ``` lean switch ``` -### 启动项目: +### 启动项目 ``` lean up From 6aa1155d612cd7829a25bc63756c90d828752e80 Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Thu, 6 Aug 2020 14:45:48 +0800 Subject: [PATCH 18/38] docs: add README in English --- README-zh.md | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 56 +++++++++++++++++++++------------------------------- 2 files changed, 76 insertions(+), 34 deletions(-) create mode 100644 README-zh.md diff --git a/README-zh.md b/README-zh.md new file mode 100644 index 0000000..60ce0a9 --- /dev/null +++ b/README-zh.md @@ -0,0 +1,54 @@ +# Flask-getting-started + +一个简单的使用 Flask 的 Python 应用。 +可以运行在 LeanEngine Python 运行时环境。 + +## 本地运行 + +首先确认本机已经安装 [Python](http://python.org/) 运行环境和 [LeanCloud 命令行工具](https://leancloud.cn/docs/leanengine_cli.html#hash1443149115),然后执行下列指令: + +``` +$ git clone git@github.com:leancloud/python-getting-started.git +$ cd python-getting-started +``` + +### 安装依赖 + +``` +pip install -r requirements.txt +``` + +### 关联应用 + +``` +lean switch +``` + +### 启动项目 + +``` +lean up +``` + +应用即可启动运行:[localhost:3000](http://localhost:3000) + +## 部署到 LeanEngine + +部署到预备环境(若无预备环境则直接部署到生产环境): +``` +lean deploy +``` + +将预备环境的代码发布到生产环境: +``` +lean publish +``` + +## 相关文档 + +* [网站托管开发指南 · Python](https://leancloud.cn/docs/leanengine_webhosting_guide-python.html) +* [云函数开发指南 · Python](https://leancloud.cn/docs/leanengine_cloudfunction_guide-python.html) +* [数据存储开发指南 · Python](https://leancloud.cn/docs/leanstorage_guide-python.html) +* [Python SDK API](https://leancloud.github.io/python-sdk/) +* [LeanCloud 命令行工具详解](https://leancloud.cn/docs/leanengine_cli.html) +* [云引擎常见问题和解答](https://leancloud.cn/docs/leanengine_faq.html) diff --git a/README.md b/README.md index c28f3a7..cc4d072 100644 --- a/README.md +++ b/README.md @@ -1,54 +1,42 @@ # Flask-getting-started -一个简单的使用 Flask 的 Python 应用。 -可以运行在 LeanEngine Python 运行时环境。 +A simple Python application based on Flask for LeanEngine Python runtime. -## 本地运行 +[中文 README](/README-zh.md) -首先确认本机已经安装 [Python](http://python.org/) 运行环境和 [LeanCloud 命令行工具](https://www.leancloud.cn/docs/leanengine_cli.html),然后执行下列指令: +## Local Development -``` -$ git clone git@github.com:leancloud/python-getting-started.git -$ cd python-getting-started -``` +First make sure [Python](http://python.org/) and [lean-cli](https://docs.leancloud.app/leanengine_cli.html#hash2037210682) are installed on the machine, then run the following commands: -### 安装依赖 - -``` +```sh +# clone the repository +git clone git@github.com:leancloud/python-getting-started.git +cd python-getting-started +# install dependencies pip install -r requirements.txt -``` - -### 关联应用 - -``` +# connect LeanCloud application lean switch -``` - -### 启动项目 - -``` +# run the project locally lean up ``` -应用即可启动运行:[localhost:3000](http://localhost:3000) +Open http://localhost:3000 in your browser to view the homepage of your project. -## 部署到 LeanEngine +## Deploy to LeanEngine + +Run the following command to deploy your project to the production environment (if you haven't purchased a standard instance): -部署到预备环境(若无预备环境则直接部署到生产环境): ``` lean deploy ``` -将预备环境的代码发布到生产环境: -``` -lean publish -``` +If you have purchased a standard instance, your project will be deployed to the staging environment first when you run `lean deploy`. +You need to run `lean publish` to deploy the code in the staging environment to the production environment. -## 相关文档 +## Documentation -* [网站托管开发指南 · Python](https://leancloud.cn/docs/leanengine_webhosting_guide-python.html) -* [云函数开发指南 · Python](https://leancloud.cn/docs/leanengine_cloudfunction_guide-python.html) -* [数据存储开发指南 · Python](https://leancloud.cn/docs/leanstorage_guide-python.html) +* [Python Web Hosting Guide](https://docs.leancloud.app/leanengine_webhosting_guide-python.html) +* [Python Cloud Function Guide](https://docs.leancloud.app/leanengine_cloudfunction_guide-python.html) +* [LeanStorage Python Guide](https://docs.leancloud.app/leanstorage_guide-python.html) * [Python SDK API](https://leancloud.github.io/python-sdk/) -* [LeanCloud 命令行工具详解](https://leancloud.cn/docs/leanengine_cli.html) -* [云引擎常见问题和解答](https://leancloud.cn/docs/leanengine_faq.html) +* [lean-cli Guide](https://docs.leancloud.app/leanengine_cli.html) From 7fe55cf48a2f9b2f4449ece6c07c00ba0869ba3f Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Thu, 6 Aug 2020 15:41:54 +0800 Subject: [PATCH 19/38] docs: simplify README --- README-zh.md | 54 ---------------------------------------------------- README.md | 31 ------------------------------ 2 files changed, 85 deletions(-) delete mode 100644 README-zh.md diff --git a/README-zh.md b/README-zh.md deleted file mode 100644 index 60ce0a9..0000000 --- a/README-zh.md +++ /dev/null @@ -1,54 +0,0 @@ -# Flask-getting-started - -一个简单的使用 Flask 的 Python 应用。 -可以运行在 LeanEngine Python 运行时环境。 - -## 本地运行 - -首先确认本机已经安装 [Python](http://python.org/) 运行环境和 [LeanCloud 命令行工具](https://leancloud.cn/docs/leanengine_cli.html#hash1443149115),然后执行下列指令: - -``` -$ git clone git@github.com:leancloud/python-getting-started.git -$ cd python-getting-started -``` - -### 安装依赖 - -``` -pip install -r requirements.txt -``` - -### 关联应用 - -``` -lean switch -``` - -### 启动项目 - -``` -lean up -``` - -应用即可启动运行:[localhost:3000](http://localhost:3000) - -## 部署到 LeanEngine - -部署到预备环境(若无预备环境则直接部署到生产环境): -``` -lean deploy -``` - -将预备环境的代码发布到生产环境: -``` -lean publish -``` - -## 相关文档 - -* [网站托管开发指南 · Python](https://leancloud.cn/docs/leanengine_webhosting_guide-python.html) -* [云函数开发指南 · Python](https://leancloud.cn/docs/leanengine_cloudfunction_guide-python.html) -* [数据存储开发指南 · Python](https://leancloud.cn/docs/leanstorage_guide-python.html) -* [Python SDK API](https://leancloud.github.io/python-sdk/) -* [LeanCloud 命令行工具详解](https://leancloud.cn/docs/leanengine_cli.html) -* [云引擎常见问题和解答](https://leancloud.cn/docs/leanengine_faq.html) diff --git a/README.md b/README.md index cc4d072..1eebbf2 100644 --- a/README.md +++ b/README.md @@ -2,37 +2,6 @@ A simple Python application based on Flask for LeanEngine Python runtime. -[中文 README](/README-zh.md) - -## Local Development - -First make sure [Python](http://python.org/) and [lean-cli](https://docs.leancloud.app/leanengine_cli.html#hash2037210682) are installed on the machine, then run the following commands: - -```sh -# clone the repository -git clone git@github.com:leancloud/python-getting-started.git -cd python-getting-started -# install dependencies -pip install -r requirements.txt -# connect LeanCloud application -lean switch -# run the project locally -lean up -``` - -Open http://localhost:3000 in your browser to view the homepage of your project. - -## Deploy to LeanEngine - -Run the following command to deploy your project to the production environment (if you haven't purchased a standard instance): - -``` -lean deploy -``` - -If you have purchased a standard instance, your project will be deployed to the staging environment first when you run `lean deploy`. -You need to run `lean publish` to deploy the code in the staging environment to the production environment. - ## Documentation * [Python Web Hosting Guide](https://docs.leancloud.app/leanengine_webhosting_guide-python.html) From d6a553332a0088f46b03c29aa8a3950414eab384 Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Fri, 7 Aug 2020 16:27:15 +0800 Subject: [PATCH 20/38] test: add integreted test --- lean.yml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 lean.yml diff --git a/lean.yml b/lean.yml new file mode 100644 index 0000000..b99acef --- /dev/null +++ b/lean.yml @@ -0,0 +1,37 @@ +name: Test Deploy to LeanEngine + +on: + push: + branches: [ master ] + paths-ignore: + - '**.md' + + pull_request: + branches: [ master ] + paths-ignore: + - '**.md' + +jobs: + build: + + runs-on: ubuntu-latest + steps: + - name: Install lean-cli + run: | + wget --quiet -O /usr/local/bin/lean https://github.com/leancloud/lean-cli/releases/download/v0.23.0/lean-linux-x64 + chmod a+x /usr/local/bin/lean + + - name: Login + env: + LC_USER: ${{ secrets.LEANCLICI }} + PASSWORD: ${{ secrets.PASSWORD }} + run: lean login --username $LC_USER --password $PASSWORD --region US + + - name: Connect + env: + APPID: ${{ secrets.PYTHON_FLASK_CI }} + run: lean switch --region US --group web $APPID + + - name: Deploy + run: lean deploy + From 48f726d6197fe1e1ae458019461e34c290fdf3e2 Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Fri, 7 Aug 2020 16:52:26 +0800 Subject: [PATCH 21/38] test: fix path error --- lean.yml => .github/workflows/lean.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename lean.yml => .github/workflows/lean.yml (100%) diff --git a/lean.yml b/.github/workflows/lean.yml similarity index 100% rename from lean.yml rename to .github/workflows/lean.yml From 66088d5aaeb0cac51999d7f7ce92228958053d50 Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Fri, 7 Aug 2020 18:50:12 +0800 Subject: [PATCH 22/38] Fix GitHub action (#37) --- .github/workflows/lean.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lean.yml b/.github/workflows/lean.yml index b99acef..7b86ae6 100644 --- a/.github/workflows/lean.yml +++ b/.github/workflows/lean.yml @@ -18,19 +18,23 @@ jobs: steps: - name: Install lean-cli run: | - wget --quiet -O /usr/local/bin/lean https://github.com/leancloud/lean-cli/releases/download/v0.23.0/lean-linux-x64 - chmod a+x /usr/local/bin/lean + wget --quiet -O lean https://github.com/leancloud/lean-cli/releases/download/v0.23.0/lean-linux-x64 + sudo mv lean /usr/local/bin/lean + chmod a+x /usr/local/bin/lean - name: Login env: LC_USER: ${{ secrets.LEANCLICI }} PASSWORD: ${{ secrets.PASSWORD }} - run: lean login --username $LC_USER --password $PASSWORD --region US + run: lean login --username "$LC_USER" --password "$PASSWORD" --region US + + - name: Checkout code + uses: actions/checkout@v2 - name: Connect env: APPID: ${{ secrets.PYTHON_FLASK_CI }} - run: lean switch --region US --group web $APPID + run: lean switch --region US --group web "$APPID" - name: Deploy run: lean deploy From 1c7707e4e87ffdf1c179a647948a786a593c89f9 Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Mon, 10 Aug 2020 22:41:10 +0800 Subject: [PATCH 23/38] docs: change comment & UI to English (#38) * docs: change comment & UI to English * fix: wording * fix: format Co-authored-by: Fuchen Shi <44103628+shifuchen98@users.noreply.github.com> --- app.py | 4 ++-- cloud.py | 2 +- templates/index.html | 8 ++++---- templates/todos.html | 2 +- views/todos.py | 2 +- wsgi.py | 7 ++++--- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/app.py b/app.py index c67b01b..91a9fcc 100644 --- a/app.py +++ b/app.py @@ -13,7 +13,7 @@ app = Flask(__name__) sockets = Sockets(app) -# 动态路由 +# routing app.register_blueprint(todos_view, url_prefix='/todos') @@ -98,7 +98,7 @@ def todos(): try: todo_list = leancloud.Query(leancloud.Object.extend('Todo')).descending('createdAt').find() except LeanCloudError as e: - if e.code == 101: # 服务端对应的 Class 还没创建 + if e.code == 101: # Class does not exist on the cloud. return jsonify([]) else: raise BadGateway(e.error, e.code) diff --git a/cloud.py b/cloud.py index 18fecd2..504ea82 100644 --- a/cloud.py +++ b/cloud.py @@ -18,6 +18,6 @@ def hello(**params): def before_todo_save(todo): content = todo.get('content') if not content: - raise LeanEngineError('内容不能为空') + raise LeanEngineError('Content cannot be empty!') if len(content) >= 240: todo.set('content', content[:240] + ' ...') diff --git a/templates/index.html b/templates/index.html index 3d643a9..210a296 100644 --- a/templates/index.html +++ b/templates/index.html @@ -7,10 +7,10 @@ diff --git a/templates/todos.html b/templates/todos.html index b4a2677..345ff74 100644 --- a/templates/todos.html +++ b/templates/todos.html @@ -9,7 +9,7 @@

{{ title }}

- +
    {% for todo in todos %} diff --git a/views/todos.py b/views/todos.py index 5e7bb54..d68cce2 100644 --- a/views/todos.py +++ b/views/todos.py @@ -21,7 +21,7 @@ def show(): try: todos = Query(Todo).descending('createdAt').find() except LeanCloudError as e: - if e.code == 101: # 服务端对应的 Class 还没创建 + if e.code == 101: # Class does not exist on the cloud. todos = [] else: raise e diff --git a/wsgi.py b/wsgi.py index c12c8cf..ee318a2 100644 --- a/wsgi.py +++ b/wsgi.py @@ -16,15 +16,16 @@ PORT = int(os.environ['LEANCLOUD_APP_PORT']) leancloud.init(APP_ID, app_key=APP_KEY, master_key=MASTER_KEY) -# 如果需要使用 master key 权限访问 LeanCLoud 服务,请将这里设置为 True +# Set this to be True if you need to access LeanCloud services with Master Key. leancloud.use_master_key(False) -# 需要重定向到 HTTPS 可去除下一行的注释。 +# Uncomment the following line to redirect HTTP requests to HTTPS. # app = leancloud.HttpsRedirectMiddleware(app) app = engine.wrap(app) application = app -# 以下代码只在本地开发环境执行 +# The code below will only be executed locally (`lean up`), +# and will not be executed on the cloud. if __name__ == '__main__': from gevent.pywsgi import WSGIServer From d42669f3d4a5f36de208feb4eed640e802f48f4c Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Wed, 9 Sep 2020 04:09:59 +0000 Subject: [PATCH 24/38] docs: supported python versions (#39) --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 1eebbf2..d273f45 100644 --- a/README.md +++ b/README.md @@ -9,3 +9,12 @@ A simple Python application based on Flask for LeanEngine Python runtime. * [LeanStorage Python Guide](https://docs.leancloud.app/leanstorage_guide-python.html) * [Python SDK API](https://leancloud.github.io/python-sdk/) * [lean-cli Guide](https://docs.leancloud.app/leanengine_cli.html) + +## Supported Python Versions + +This project supports the following Python versions (the same as [LeanCloud Python SDK][sdk]): + +- Python 2.7 +- Python 3.5, 3.6, 3.7, 3.8 + +[sdk]: https://github.com/leancloud/python-sdk \ No newline at end of file From 7e52cc2de45b0850e4460aed7738a6f14927135f Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Thu, 26 Nov 2020 14:29:36 +0800 Subject: [PATCH 25/38] feat: upgrade python from 3.7 to 3.8 (#40) The maintainmance status of 3.7 is security only, no bugfix. The maintainmance status of 3.8 is bugfix. The maintainmance status of 3.9 is also bugfix but Ubuntu 20.04 does not ship Python 3.9. --- .python-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.python-version b/.python-version index c1e43e6..2e14a95 100644 --- a/.python-version +++ b/.python-version @@ -1 +1 @@ -3.7.3 +3.8.6 From 3fd19cdc9c0d076fad162f673c67b62e48fbefb8 Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Wed, 3 Mar 2021 12:31:31 +0800 Subject: [PATCH 26/38] feat: drop support for Python 3.5 (#41) --- .python-version | 2 +- README.md | 2 +- requirements.txt | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.python-version b/.python-version index 2e14a95..4351a7e 100644 --- a/.python-version +++ b/.python-version @@ -1 +1 @@ -3.8.6 +3.8.7 diff --git a/README.md b/README.md index d273f45..4d5046d 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,6 @@ A simple Python application based on Flask for LeanEngine Python runtime. This project supports the following Python versions (the same as [LeanCloud Python SDK][sdk]): - Python 2.7 -- Python 3.5, 3.6, 3.7, 3.8 +- Python 3.6, 3.7, 3.8, 3.9 [sdk]: https://github.com/leancloud/python-sdk \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index e565443..13e5865 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,4 @@ -gevent>=1.0.2,<2.0.0 gevent-websocket>=0.9.5,<1.0.0 -leancloud>=2.5.1,<3.0.0 +leancloud>=2.9.1,<3.0.0 Flask>=1.0.0 Flask-Sockets>=0.1,<1.0 -typing From 8c08c2da53bca37f6ce7300a23d7488d98e6f68d Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Tue, 18 May 2021 17:43:41 +0800 Subject: [PATCH 27/38] fix: downgrade werkzeug to 0.16.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit werkzeug 1.0.0 brings in some incompatibilities. Thus werkzeug is downgraded to 0.16.0 as a hot fix. Thank 赤枫 for bringing this to our attention. --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 13e5865..fc3a0dc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ +werkzeug==0.16.0 gevent-websocket>=0.9.5,<1.0.0 leancloud>=2.9.1,<3.0.0 Flask>=1.0.0 From 77a131fe1ea2392d3438fc5dd4e1c5bf53cf82a6 Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Tue, 18 May 2021 18:48:08 +0800 Subject: [PATCH 28/38] build: upgrade lean-cli version --- .github/workflows/lean.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lean.yml b/.github/workflows/lean.yml index 7b86ae6..6682f49 100644 --- a/.github/workflows/lean.yml +++ b/.github/workflows/lean.yml @@ -18,7 +18,7 @@ jobs: steps: - name: Install lean-cli run: | - wget --quiet -O lean https://github.com/leancloud/lean-cli/releases/download/v0.23.0/lean-linux-x64 + wget --quiet -O lean https://github.com/leancloud/lean-cli/releases/download/v0.24.4/lean-linux-x64 sudo mv lean /usr/local/bin/lean chmod a+x /usr/local/bin/lean @@ -26,7 +26,7 @@ jobs: env: LC_USER: ${{ secrets.LEANCLICI }} PASSWORD: ${{ secrets.PASSWORD }} - run: lean login --username "$LC_USER" --password "$PASSWORD" --region US + run: lean login --username "$LC_USER" --password "$PASSWORD" --region us-w1 - name: Checkout code uses: actions/checkout@v2 From 5313b6c8a5dffc30a70e7dd48528b7962d5afa03 Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Wed, 19 May 2021 08:58:28 +0800 Subject: [PATCH 29/38] fix: upgrade leancloud python sdk to 2.9.3 --- requirements.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index fc3a0dc..9197de0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,4 @@ -werkzeug==0.16.0 gevent-websocket>=0.9.5,<1.0.0 -leancloud>=2.9.1,<3.0.0 +leancloud>=2.9.3,<3.0.0 Flask>=1.0.0 Flask-Sockets>=0.1,<1.0 From b09a2e6a1c4e341023b5c925792000d0ac825384 Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Tue, 25 May 2021 15:20:09 +0800 Subject: [PATCH 30/38] chore: update python minor version This is just for triggering the updated webhook to publish new code to pack-scaffold. --- .python-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.python-version b/.python-version index 4351a7e..d20cc2b 100644 --- a/.python-version +++ b/.python-version @@ -1 +1 @@ -3.8.7 +3.8.10 From a1107b9b24e9a356ffa705285af9ffd18b1360fc Mon Sep 17 00:00:00 2001 From: Chen Shuaimin Date: Fri, 11 Jun 2021 11:39:25 +0800 Subject: [PATCH 31/38] feat: specify custom run command --- leanengine.yaml | 1 + wsgi.py | 34 +++++++++++++++++++++------------- 2 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 leanengine.yaml diff --git a/leanengine.yaml b/leanengine.yaml new file mode 100644 index 0000000..37c0964 --- /dev/null +++ b/leanengine.yaml @@ -0,0 +1 @@ +run: python wsgi.py diff --git a/wsgi.py b/wsgi.py index ee318a2..041cb85 100644 --- a/wsgi.py +++ b/wsgi.py @@ -24,21 +24,29 @@ app = engine.wrap(app) application = app -# The code below will only be executed locally (`lean up`), -# and will not be executed on the cloud. if __name__ == '__main__': - + from gevent.pywsgi import WSGIServer from geventwebsocket.handler import WebSocketHandler - from werkzeug.serving import run_with_reloader - from werkzeug.debug import DebuggedApplication - - @run_with_reloader - def run(): - global application - app.debug = True - application = DebuggedApplication(application, evalex=True) - server = WSGIServer(('localhost', PORT), application, handler_class=WebSocketHandler) + + if os.environ['LEANCLOUD_APP_ENV'] == 'production': + class NopLogger(object): + def write(self, _): + pass + + server = WSGIServer(('', PORT), application, log=NopLogger(), handler_class=WebSocketHandler) server.serve_forever() - run() + else: + from werkzeug.serving import run_with_reloader + from werkzeug.debug import DebuggedApplication + + @run_with_reloader + def run(): + global application + app.debug = True + application = DebuggedApplication(application, evalex=True) + server = WSGIServer(('localhost', PORT), application, handler_class=WebSocketHandler) + server.serve_forever() + + run() From 73aa3681271f00d36e0a4078e7c7aaddbff0170b Mon Sep 17 00:00:00 2001 From: Chen Shuaimin Date: Tue, 15 Jun 2021 11:55:06 +0800 Subject: [PATCH 32/38] listen on 0.0.0.0 in staging environment --- wsgi.py | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/wsgi.py b/wsgi.py index 041cb85..44e37cd 100644 --- a/wsgi.py +++ b/wsgi.py @@ -25,28 +25,19 @@ application = app if __name__ == '__main__': - from gevent.pywsgi import WSGIServer from geventwebsocket.handler import WebSocketHandler - if os.environ['LEANCLOUD_APP_ENV'] == 'production': - class NopLogger(object): - def write(self, _): - pass - - server = WSGIServer(('', PORT), application, log=NopLogger(), handler_class=WebSocketHandler) + env = os.environ['LEANCLOUD_APP_ENV'] + if env == 'production': + server = WSGIServer(('0.0.0.0', PORT), application, log=None, handler_class=WebSocketHandler) server.serve_forever() - else: from werkzeug.serving import run_with_reloader from werkzeug.debug import DebuggedApplication - @run_with_reloader - def run(): - global application - app.debug = True - application = DebuggedApplication(application, evalex=True) - server = WSGIServer(('localhost', PORT), application, handler_class=WebSocketHandler) - server.serve_forever() - - run() + app.debug = True + application = DebuggedApplication(application, evalex=True) + address = 'localhost' if env == 'development' else '0.0.0.0' + server = WSGIServer((address, PORT), application, handler_class=WebSocketHandler) + run_with_reloader(server.serve_forever) From 644dc911dd34f07f8c26f3a72cf4999bf05daeaf Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Fri, 25 Jun 2021 16:04:13 +0800 Subject: [PATCH 33/38] build: update lean-cli --- .github/workflows/lean.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lean.yml b/.github/workflows/lean.yml index 6682f49..af8d32d 100644 --- a/.github/workflows/lean.yml +++ b/.github/workflows/lean.yml @@ -18,7 +18,7 @@ jobs: steps: - name: Install lean-cli run: | - wget --quiet -O lean https://github.com/leancloud/lean-cli/releases/download/v0.24.4/lean-linux-x64 + wget --quiet -O lean https://github.com/leancloud/lean-cli/releases/download/v0.25.0/lean-linux-x64 sudo mv lean /usr/local/bin/lean chmod a+x /usr/local/bin/lean From fcd8e47bcb19d552d17daa9f696bc39500173044 Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Fri, 25 Jun 2021 16:19:25 +0800 Subject: [PATCH 34/38] build: lean login with token --- .github/workflows/lean.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lean.yml b/.github/workflows/lean.yml index af8d32d..79da5e9 100644 --- a/.github/workflows/lean.yml +++ b/.github/workflows/lean.yml @@ -24,9 +24,8 @@ jobs: - name: Login env: - LC_USER: ${{ secrets.LEANCLICI }} - PASSWORD: ${{ secrets.PASSWORD }} - run: lean login --username "$LC_USER" --password "$PASSWORD" --region us-w1 + TOKEN: ${{ secrets.ACCESS_TOKEN }} + run: lean login --token "$TOKEN" - name: Checkout code uses: actions/checkout@v2 From c3768bb4029730182c895d6d3142fc32e135ea4f Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Tue, 13 Jul 2021 13:16:40 +0800 Subject: [PATCH 35/38] feat: upgrade leancloud to 2.9.4 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 9197de0..85d3679 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ gevent-websocket>=0.9.5,<1.0.0 -leancloud>=2.9.3,<3.0.0 +leancloud>=2.9.4,<3.0.0 Flask>=1.0.0 Flask-Sockets>=0.1,<1.0 From dc88d583eb3e95e12cd62dd5648e3f7b4b3ac130 Mon Sep 17 00:00:00 2001 From: Jang Rush Date: Wed, 14 Jul 2021 12:09:35 +0800 Subject: [PATCH 36/38] build: fix github workflow add missing region argument for lean-cli close #47 --- .github/workflows/lean.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lean.yml b/.github/workflows/lean.yml index 79da5e9..a567ec4 100644 --- a/.github/workflows/lean.yml +++ b/.github/workflows/lean.yml @@ -25,7 +25,7 @@ jobs: - name: Login env: TOKEN: ${{ secrets.ACCESS_TOKEN }} - run: lean login --token "$TOKEN" + run: lean login --region us-w1 --token "$TOKEN" - name: Checkout code uses: actions/checkout@v2 From deff36433fa316e906e8879de9c97f1975122509 Mon Sep 17 00:00:00 2001 From: Chen Shuaimin Date: Mon, 9 May 2022 13:06:48 +0800 Subject: [PATCH 37/38] fix ImportError: cannot import name 'soft_unicode' from 'markupsafe' --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 85d3679..201f3e3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ gevent-websocket>=0.9.5,<1.0.0 leancloud>=2.9.4,<3.0.0 +markupsafe<=2.0.1 Flask>=1.0.0 Flask-Sockets>=0.1,<1.0 From 76c62649090379833951e61fc6a6f259df0e0327 Mon Sep 17 00:00:00 2001 From: Fuchen Shi Date: Tue, 10 May 2022 13:03:45 +0800 Subject: [PATCH 38/38] test: update commands for deploying to LeanEngine --- .github/workflows/lean.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lean.yml b/.github/workflows/lean.yml index a567ec4..e1e6123 100644 --- a/.github/workflows/lean.yml +++ b/.github/workflows/lean.yml @@ -18,7 +18,7 @@ jobs: steps: - name: Install lean-cli run: | - wget --quiet -O lean https://github.com/leancloud/lean-cli/releases/download/v0.25.0/lean-linux-x64 + wget --quiet -O lean https://github.com/leancloud/lean-cli/releases/download/v1.0.0/lean-linux-x64 sudo mv lean /usr/local/bin/lean chmod a+x /usr/local/bin/lean @@ -36,5 +36,5 @@ jobs: run: lean switch --region US --group web "$APPID" - name: Deploy - run: lean deploy + run: lean deploy --prod