login_bp = Blueprint("login_bp", __name__, url_prefix="/api/v1")
class LoginView(Resource):
@marshal_with(user_fields)
def get(self):
users = User.query.all()
# print(users)
return users
# return {"code":0 ,"msg": "中文测试"}
api.add_resource(LoginView, "/login")

1
ropon OP 请问有遇到过没呢?如何解决呢
|
2
ChanKc 2020 年 7 月 30 日
你这不是已经有答案了?
如果客户端是你控制,让客户端发 Accept-Charset |
3
johnsona 2020 年 7 月 30 日
ensure_ascii=False
|
4
ropon OP 换句话说返回 Content-Type 如何配置
难道是通过 api.representations = OrderedDict({'application/json;charset=utf-8': output_json}) JSON_AS_ASCII = False JSONIFY_MIMETYPE = "application/json;charset=utf-8" RESTFUL_JSON = dict(ensure_ascii=False) @jsisjs20130824 测试 demo 地址 https://github.com/Ropon/apidemo,请问各位帮忙看下呢 |
5
ropon OP 测试 demo 地址 https://github.com/Ropon/apidemo
|
6
ruanimal 2020 年 7 月 31 日
你得看一下返回的原始数据是啥
|
8
ruanimal 2020 年 7 月 31 日
用开发者工具看网络请求的 response,而不是贴文本啊
|
10
renmu123 2020 年 7 月 31 日 via Android
(推荐一波 fastapi,爽是真的爽
|
11
ropon OP |
12
ropon OP |
13
Cookieeeeee 2020 年 7 月 31 日
用的 python2 吗
|
14
ByteMind 2020 年 7 月 31 日
你为什么可以发照片
|
16
ropon OP @Cookieeeeee python 3
|
17
ropon OP @jsisjs20130824 配置了,还是乱码,方便测试帮忙看下吗?
|
18
kucoll 2020 年 11 月 12 日
falsk_resutful 没用过,不过 flask 中可以配置返回 json 的媒体类型:
JSONIFY_MIMETYPE = "application/json;charset=UTF-8" 参考文档: https://dormousehole.readthedocs.io/en/latest/config.html?highlight=jsonify_mimetype#JSONIFY_MIMETYPE |