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-07-30 23:18:58 +08:00 你这不是已经有答案了? 如果客户端是你控制,让客户端发 Accept-Charset |
![]() | 3 johnsona 2020-07-30 23:56:58 +08:00 ensure_ascii=False |
![]() | 4 ropon OP 换句话说返回 Content-Type 如何配置 难道是通过 api.representatiOns= OrderedDict({'application/json;charset=': output_json}) JSON_AS_ASCII = False JSONIFY_MIMETYPE = "application/json;charset=" 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-07-31 09:53:59 +08:00 你得看一下返回的原始数据是啥 |
![]() | 8 ruanimal 2020-07-31 10:10:37 +08:00 用开发者工具看网络请求的 response,而不是贴文本啊 |
10 renmu123 2020-07-31 12:37:05 +08:00 via Android (推荐一波 fastapi,爽是真的爽 |
![]() | 11 ropon OP |
![]() | 12 ropon OP |
13 Cookieeeeee 2020-07-31 15:35:15 +08:00 用的 python2 吗 |
![]() | 14 perpetually 2020-07-31 17:14:55 +08:00 你为什么可以发照片 |
![]() | 16 ropon OP @Cookieeeeee python3 |
![]() | 17 ropon OP @jsisjs20130824 配置了,还是乱码,方便测试帮忙看下吗? |
18 kucoll 2020-11-12 16:38:36 +08:00 falsk_resutful 没用过,不过 flask 中可以配置返回 json 的媒体类型: JSONIFY_MIMETYPE = "application/json;charset=" 参考文档: https://dormousehole.readthedocs.io/en/latest/config.html?highlight=jsonify_mimetype#JSONIFY_MIMETYPE |