文档: http://blog.miguelgrinberg.com/post/designing-a-restful-api-with-python-and-flask
快速入门: http://www.pythondoc.com/flask/quickstart.html
Python以及Flask的安装: http://blog.csdn.net/qwiwuqo/article/details/8970621
1. 安装python2.x
2. 安装esay_install
3. 安装Flask:
1> 打开控制台:,输入easy_install virtualenv, 安装virtualenv
2> 配置虚拟环境: virtualenv myvir,相应路径下会多一个文件夹myvir
3> 在myvir目录的Scripts下,输入activate.bat进入虚拟环境,然后输入esay_install Flask
4> 控制台输入python hello.py
5> 浏览器输入http://127.0.0.1:500访问对应的api
示例,hello.py文件:
from flask import Flask app=Flask(__name__) @app.route('/') def hello_world(): return "Hello World" if __name__ == '__main__': app.run()
示例,bookItems.py:
from flask import Flask, jsonify from flask import abort app = Flask(__name__) bookItems = [ { "id": "1000", "name": "groovy", "price": "30", "author": "Jack" }, { "id": "1001", "name": "java", "price": "32", "author": "Jimmy" }, { "id": "1002", "name": "c#", "price": "32", "author": "Jimmy" }, { "id": "1003", "name": "html", "price": "32", "author": "Jimmy" }, { "id": "1004", "name": "english", "price": "32", "author": "Jimmy" }, { "id": "1005", "name": "sport", "price": "32", "author": "Jimmy" } ] @app.route('/api/v1/books', methods=['GET']) def get_bookItems(): return jsonify({'books': bookItems}) @app.route('/api/v1/books/<book_id>', methods=['GET']) def get_book(book_id): book = [book for book in bookItems if book['id'] == book_id] if len(book) == 0: abort(404) return jsonify({'book': book[0]}) if __name__ == '__main__': app.run(debug = True)
相关推荐
Designing Machine Learning Systems with Python 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
Designing-a-RESTful-API-with-Python-and-FlaskDesigning-a-RESTful-API-with-Python-and-Flask 系列中文翻译。docs 文件夹为原始版中文翻译;docs_release 文件夹为发布版中文翻译,里面嵌入了统计以及广告代码...
Designing Machine Learning Systems with Python 2016 {PRG} Designing Machine Learning Systems with Python 2016 {PRG}
《Designing Machine Learning Systems with Python 2016》是一本深入探讨如何使用Python构建高效机器学习系统的专著。作者David Julian以其丰富的经验,引导读者理解如何设计出能提供更准确结果的机器学习系统。这...
Designing Machine Learning Systems with Python 英文mobi 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
It also covers how to optimize and explore endpoints for microservices with API gateways and touches upon integrated platforms and Hubs for RESTful APIs. You'll also understand how application ...
analysis for the shared study room reservation system based on the Python Flask framework, delving into the functionalities the system should possess and designing a comprehensive database. Utilizing...
Designing Machine Learning Systems with Python 英文无水印pdf pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有...
It has applications in a wide range of fields, including economics, the natural sciences, web development, and business modeling. In order to harness the power of these systems, it is essential that ...
Programming a computer and designing algorithms for understanding what is in these images is the field of computer vision. Computer vision powers applications like image search, robot navigation, ...
But finding algorithms and designing and building platforms that deal with large sets of data is a growing need. Data scientists have to manage and maintain increasingly complex data projects, and ...
Rapid GUI programming with Python and Qt 1 Contents 8 Foreword 14 Introduction 16 Part I: Python Programming 22 Chapter 1. Data Types and Data Structures 24 Executing Python Code 25 Variables ...
You’ll explore the concepts behind REST, learn different strategies for creating hypermedia-based APIs, and then put everything together with a step-by-step guide to designing a RESTful Web API.
An overview of problem solving and simple Python programs, introducing the basic models and techniques for designing and implementing problem solutions, independent of software and hardware tools ...
Building RESTful Web Services with Spring 5 – Second Edition: Leverage the power of Spring 5.0, Java SE 9, and Spring Boot 2.0 Find out how to implement the REST architecture to build resilient ...
Ideal for experienced NET developers this book’s sections on basic Web API theory and design also apply to developers who work with other development stacks such as Java Ruby PHP and Node ...
This book, "Flask By Example," aims to guide readers through the process of creating sophisticated web applications using Flask, catering to those familiar with Python fundamentals and interested in ...
This book will give you expertise on how to employ various NLP tasks in Python, giving you an insight into the best practices when designing and building NLP-based applications using Python....