Reputation: 140
I am trying to use flask-restful api, and as a returning value the code should returning a list of json datas. However, when contents in json is non-ascii character like (èòsèèò) the returning value
This is the a sample code:
#! /usr/bin/env python
# coding: utf-8
from flask import Flask, Response
from flask_restful import Resource, Api
import json
app = Flask(__name__)
# Create the API
API = Api(app)
@app.route('/')
def hello_world():
return Response('Here, with Response it works well: höne')
class APICLASS(Resource):
"""
"""
def get(self, id):
return [
{
"hey": 11,
"test": "höne"
}], 200
API.add_resource(APICLASS, '/<string:id>')
if __name__ == '__main__':
app.run(debug=True)
But when I check the result on localhost, I see the following output:
[
{
"hey": 11,
"test": "h\u00f6ne"
}]
Upvotes: 3
Views: 1941