当前位置:首页 > Windows程序 > 正文

flask实现api

2024-03-31 Windows程序

from flask import Flask, jsonify app = Flask(__name__) tasks = [ { ‘id‘: 1, ‘title‘: u‘Buy groceries‘, ‘description‘: u‘Milk, Cheese, Pizza, Fruit, Tylenol‘, ‘done‘: False }, { ‘id‘: 2, ‘title‘: u‘Learn Python‘, ‘description‘: u‘Need to find a good Python tutorial on the web‘, ‘done‘: False } ] @app.route(‘/todo/api/v1.0/tasks‘, methods=[‘GET‘]) def get_tasks(): return jsonify({‘tasks‘: tasks}) if __name__ == ‘__main__‘: app.run(debug=True)

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/34265.html

Jm-杰米博客Jamie
草根站长的技术交流乐园!IT不会不要紧快来好好学习吧!
  • 20786文章总数
  • 7494588访问次数
  • 建站天数
  • 友情链接