python get the simple interface for a front end data acquisition json

First you need to install pip install Flask

from flask import Flask
from flask import jsonify
app = Flask(__name__)
json_data = {
            'BL_status': '1', 
            'error': 0,
            'data_num': 1, 
            'content': {
                'BL': '4434', 
                }
            }

# GET, 根据用户ID查询特定用户
@app.route('/', methods=['GET'])
def get_json():
    # usr = [user for user in users if (user['id'] == userId)]
    return jsonify(json_data)

#也可以自定义其他的方法

# 设定监听端口为8889
if __name__ == '__main__':
    app.run(host='127.0.0.1', port=9999)

Access browser or other test interface tool

http://127.0.0.1:9999/

You can get the data

 

Guess you like

Origin blog.csdn.net/cp_123321/article/details/93307902