Getting Started with the API of Langman
Explore how to build the Langman REST API by creating placeholder routes, connecting to the database, and managing HTTP methods with Flask. Understand API namespaces, use flask-cors for cross-origin resource sharing, and run the API locally to test unimplemented routes.
We'll cover the following...
Stubbing out the app
In this chapter, we’ll use API design principles. First, we stub out the application, that is, create do-nothing methods as placeholders, and its routes. We then create the database connection and fill in the routes. The configuration parameters are stored in the config.yaml file.
The primary advantage of using an API namespace is that the API can be specified first in one file and then added to the app in a different file. Also, it is possible to define a collection of API pieces and then assemble them into one app at the end. For example, authentication and administration interactions can be put at the /auth and /admin base routes. Notice that the games resource path is an empty string. It is then attached to games ...