提供更便利的获取用户单词表的方法,以json数据格式返回 #93

Merged
mrlan merged 7 commits from SPM2023S-QianJunQi into Alpha-snapshot20240618 2024-08-31 07:39:01 +08:00

1、注册了一个新的蓝图路径以供功能实现
2、wordCMD中完成功能的代码代码实现

1、注册了一个新的蓝图路径以供功能实现 2、wordCMD中完成功能的代码代码实现
qianjunqi added 1 commit 2023-05-26 17:39:23 +08:00
e9ec65e7a5 提供更便利的获取用户单词表的方法,以json数据格式范围
1、注册了一个新的蓝图路径以供功能实现
2、wordCMD中完成功能的代码代码实现
mrlan reviewed 2023-05-27 08:43:35 +08:00
app/wordCMD.py Outdated
@ -0,0 +28,4 @@
d = load_freq_history(user_freq_record)
freqlst = sort_in_descending_order(pickle_idea.dict2lst(d))
print(freqlst)
words_freq=[] # 存储单词表的数组,格式为 单词-词频

@qianjunqi

= 号前后要有空格。所有的都应该如此。

@qianjunqi `=` 号前后要有空格。所有的都应该如此。
mrlan reviewed 2023-05-27 08:44:29 +08:00
app/wordCMD.py Outdated
@ -0,0 +1,37 @@
from flask import Flask, request, Blueprint, render_template, json, jsonify

@qianjunqi

这个 Blueprint 加到 wordCMD.py 中好吗?

@qianjunqi 这个 Blueprint 加到 wordCMD.py 中好吗?
mrlan reviewed 2023-05-27 08:45:02 +08:00
app/wordCMD.py Outdated
@ -0,0 +30,4 @@
print(freqlst)
words_freq=[] # 存储单词表的数组,格式为 单词-词频
for i in range(len(freqlst)):
words_freq.append(str(freqlst[i][0])+"-"+str(len(freqlst[i][1])))

@qianjunqi

+ 号前后要有空格。

@qianjunqi `+` 号前后要有空格。
mrlan reviewed 2023-05-27 09:01:24 +08:00
app/wordCMD.py Outdated
@ -0,0 +22,4 @@
def show(name):
token = request.args.get("token")
# when token is wrong
if token != TKTK:

@qianjunqi

这种方式安全性如何? 看看下面链接中 Token Authentication Example

https://flask-httpauth.readthedocs.io/en/latest/index.html

from flask import Flask
from flask_httpauth import HTTPTokenAuth

app = Flask(__name__)
auth = HTTPTokenAuth(scheme='Bearer')

tokens = {
    "secret-token-1": "john",
    "secret-token-2": "susan"
}

@auth.verify_token
def verify_token(token):
    if token in tokens:
        return tokens[token]

@app.route('/')
@auth.login_required
def index():
    return "Hello, {}!".format(auth.current_user())

if __name__ == '__main__':
    app.run()
@qianjunqi 这种方式安全性如何? 看看下面链接中 Token Authentication Example https://flask-httpauth.readthedocs.io/en/latest/index.html ``` from flask import Flask from flask_httpauth import HTTPTokenAuth app = Flask(__name__) auth = HTTPTokenAuth(scheme='Bearer') tokens = { "secret-token-1": "john", "secret-token-2": "susan" } @auth.verify_token def verify_token(token): if token in tokens: return tokens[token] @app.route('/') @auth.login_required def index(): return "Hello, {}!".format(auth.current_user()) if __name__ == '__main__': app.run() ```
qianjunqi changed title from 提供更便利的获取用户单词表的方法,以json数据格式范围 to 提供更便利的获取用户单词表的方法,以json数据格式返回 2023-06-02 11:00:07 +08:00
qianjunqi added 3 commits 2023-06-04 10:43:29 +08:00
dc37f5f229 提供更便利的获取用户单词表的方法,以json数据格式范围
1、注册了一个新的蓝图路径以供功能实现
2、wordCMD中完成功能的代码代码实现
2fb3003808 fix: 2023.6.1
1. 删去了wordCMD.py中:
from flask import ....,Blueprint,....
改为:
from flask import *
2. 修改了代码的格式,包括:等号两边的空格、加号两边的空格
3. 更新了访问用户单词的token验证
3.1 使用Authorization的字段值(Bearer xxx)验证token
3.2 取消了路由访问用户单词的功能,只能在终端命令行中输入: "curl -H "Authorization: Bearer 密钥" http://127.0.0.1:5000/show/用户名/"获取单词
mrlan changed title from 提供更便利的获取用户单词表的方法,以json数据格式返回 to 提供更便利的获取用户单词表的方法,以json数据格式返回 2024-08-31 06:56:56 +08:00
mrlan changed target branch from master to Alpha-snapshot20240618 2024-08-31 06:56:56 +08:00
mrlan added 2 commits 2024-08-31 07:36:25 +08:00
mrlan added 1 commit 2024-08-31 07:38:36 +08:00
mrlan merged commit 19ea14b38c into Alpha-snapshot20240618 2024-08-31 07:39:01 +08:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: mrlan/EnglishPal#93
There is no content yet.