Serving static resources
Web pages contain several types of static resources, such as images, videos, CSS, and so on. In this recipe, we will see how you can manage such static resources for your module.
Getting ready
For this recipe, we will display an image on the page. So, get one image ready. Also, grab the my_library
module from the previous recipe.
How to do it...
Follow these steps to show an image on the page:
- Add your image to the
/my_library/static/src/img
directory. - Define the new route in
controller
. In the code, replace the image URL with the URL of your image:@http.route('/demo_page', type='http', auth='none') def books(self): Â Â Â Â image_url = '/my_library/static/src/image/odoo.png' Â Â Â Â html_result = """<html> Â Â Â Â Â Â Â Â <body> Â Â Â Â Â Â Â Â Â Â Â Â <img...