Making a path accessible from the network
In this recipe, we'll look at how to make a URL of the http://yourserver/path1/path2
form accessible to users. This can be either a web page or a path returning arbitrary data to be consumed by other programs. In the latter case, you would usually use JSON format to consume parameters and offer your data.
Getting ready
We'll make use of the library.book
model, which we looked at in Chapter 4, Application Models; so, if you haven't done so yet, grab the initial module from https://github.com/PacktPublishing/Odoo-14-Development-Cookbook-Fourth-Edition/tree/master/Chapter13/00_initial_module, so that you will be able to follow the examples.
We want to allow any user to query the full list of books. Furthermore, we want to provide the same information to programs through a JSON request.
How to do it...
We'll need to add controllers, which go into a folder called controllers
by convention:
- Add a
controllers...