February 2018
Beginner to intermediate
364 pages
10h 32m
English
There really isn't a lot of code, which is the beauty of Flask-RESTful. The code begins with importing of flask and flask_restful.
from flask import Flaskfrom flask_restful import Resource, Api
These are followed with code to set up the initial configuration of Flask-RESTful:
app = Flask(__name__)api = Api(app)
Next comes a definition of a class which represents the implementation of our API:
class JobListing(Resource): def get(self, job_listing_id): print("Request for job listing with id: " + job_listing_id) return {'YouRequestedJobWithId': job_listing_id}
What we will have Flask-RESTful do is map HTTP requests to methods in this class. Specifically, by convention GET requests will be mapped to member functions named get. There ...
Read now
Unlock full access