From 6f6b5c0abb75c38e6357b3be36b8f31da60b519f Mon Sep 17 00:00:00 2001 From: XiaoXinYo <1104361313@qq.com> Date: Thu, 21 Sep 2023 16:11:35 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=9B=B4=E6=96=B0Issue=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/ISSUE_TEMPLATE/bug_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index c54c52f..27143d6 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -29,7 +29,7 @@ body: id: python-version attributes: label: Python Version - description: '`python3 -V`' + description: '`python -V`' validations: required: true - type: textarea From 175639d40d1b40786de01a5d31bc7c0854f2fb51 Mon Sep 17 00:00:00 2001 From: XiaoXinYo <1104361313@qq.com> Date: Thu, 21 Sep 2023 16:11:44 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=A2=9E=E5=8A=A0Wiki?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/wiki/Home.md | 1 + doc/wiki/State.md | 6 +++ doc/wiki/WebAPI.md | 96 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 doc/wiki/Home.md create mode 100644 doc/wiki/State.md create mode 100644 doc/wiki/WebAPI.md diff --git a/doc/wiki/Home.md b/doc/wiki/Home.md new file mode 100644 index 0000000..0e04e86 --- /dev/null +++ b/doc/wiki/Home.md @@ -0,0 +1 @@ +Welcome to the Roop-WebAPI Wiki. \ No newline at end of file diff --git a/doc/wiki/State.md b/doc/wiki/State.md new file mode 100644 index 0000000..02582f5 --- /dev/null +++ b/doc/wiki/State.md @@ -0,0 +1,6 @@ +Code|Illustrate +---|--- +0|Wait +1|ING +2|Success +3|Fail \ No newline at end of file diff --git a/doc/wiki/WebAPI.md b/doc/wiki/WebAPI.md new file mode 100644 index 0000000..3f64f29 --- /dev/null +++ b/doc/wiki/WebAPI.md @@ -0,0 +1,96 @@ +## Submit +### Request +1. Url: /submit. +2. Method: POST. +3. Format: Form. +4. Parameter: + +Name|Type|Require|Illustrate +---|---|---|--- +target|File|Yes| +source|File|No|Require when mode contains replace +modes|List|Yes|Only fill in replace,enhance +keepFPS|Number|No|Can be filled in when the mode contains replace,0 represents false,1 represents true +skipAudio|Number|No|Can be filled in when the mode contains replace,0 represents false,1 represents true +manyFace|Number|No|0 represents false,1 represents true +### Response +1. Format: JSON. +2. Parameter: + +Name|Type|Illustrate +---|---|--- +code|Integer| +message|String| +data|String|Token +3. Example: +```json +{ + "code": 200, + "message": "success", + "data": "1c40f444-716d-4159-a1f5-063dd0bf3978" +} +``` +## Delete +### Request +1. Url: /delete. +2. Method: POST. +3. Format: JSON. +4. Parameter: + +Name|Type|Require|Illustrate +---|---|---|--- +token|String|Yes| +### Response +1. Format: JSON. +2. Parameter: + +Name|Type|Illustrate +---|---|--- +code|Integer| +message|String| +data|String| +3. Example: +```json +{ + "code": 200, + "message": "success", + "data": "success" +} +``` +## Get State +### Request +1. Url: /get_state. +2. Method: GET. +3. Parameter: + +Name|Type|Require|Illustrate +---|---|---|--- +token|String|Yes| +### Response +1. Format: JSON. +2. Parameter: + +Name|Type|Illustrate +---|---|--- +code|Integer| +message|String| +data|Number| +3. Example: +```json +{ + "code": 200, + "message": "success", + "data": 0 +} +``` +## Download +### Request +1. Url: /download. +2. Method: GET. +3. Parameter: + +Name|Type|Require|Illustrate +---|---|---|--- +token|String|Yes| +### Response +Format: Binary. \ No newline at end of file From 357213e2a834fc4c13feafd793d48ede55175506 Mon Sep 17 00:00:00 2001 From: XiaoXinYo <1104361313@qq.com> Date: Thu, 21 Sep 2023 16:12:44 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cc729f7..fd6fab9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![Release](https://img.shields.io/badge/Release-0.1.2-blue) +![Release](https://img.shields.io/badge/Release-0.1.3-blue) --- ## Introduce [s0md3v/roop](https://github.com/s0md3v/roop) WebAPI. From f15f0e4313356eaf4825fed92de464bcb9419d25 Mon Sep 17 00:00:00 2001 From: XiaoXinYo <1104361313@qq.com> Date: Thu, 21 Sep 2023 16:26:56 +0800 Subject: [PATCH 4/5] Optimize getRequestParameter --- module/core.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/module/core.py b/module/core.py index cf7e73d..8c31fe9 100644 --- a/module/core.py +++ b/module/core.py @@ -6,9 +6,7 @@ def getRequestParameter(request: request) -> dict: if request.method == 'GET': data = request.args elif request.method == 'POST': - data = request.form - if not data: - data = request.get_json() + data = request.get_json() return dict(data) class GenerateResponse: From 8f82b224d2790054bb93ec8a224af25fe322800c Mon Sep 17 00:00:00 2001 From: XiaoXinYo <1104361313@qq.com> Date: Thu, 21 Sep 2023 16:28:54 +0800 Subject: [PATCH 5/5] delete getState support several method --- main.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index b3973e5..750adf7 100644 --- a/main.py +++ b/main.py @@ -23,7 +23,7 @@ def error500(error: Exception) -> Response: def submit() -> Response: target = request.files.get('target') source = request.files.get('source') - parameter = core.getRequestParameter(request) + parameter = request.form modes = request.form.getlist('modes') keepFPS = parameter.get('keepFPS', False) skipAudio = parameter.get('skipAudio', False) @@ -59,7 +59,7 @@ def submit() -> Response: }) return core.GenerateResponse().success(token) -@APP.post('/delete') +@APP.route('/delete', methods=['GET', 'POST']) def delete() -> Response: token = core.getRequestParameter(request).get('token') if not token: @@ -77,8 +77,8 @@ def delete() -> Response: redis.deleteTask(token) return core.GenerateResponse().success('success') -@APP.get('/get_state') -def get_state() -> Response: +@APP.route('/get_state', methods=['GET', 'POST']) +def getState() -> Response: token = core.getRequestParameter(request).get('token') if not token: return core.GenerateResponse().error(110, 'parameter cannot be empty') @@ -90,7 +90,7 @@ def get_state() -> Response: @APP.get('/download') def download() -> Response: - token = core.getRequestParameter(request).get('token') + token = request.get_json().get('token') if not token: return core.GenerateResponse().error(110, 'parameter cannot be empty')