Hello World!

To provide our first web page, we will add a controller object. We will begin by having this file imported with the module:

  1. First, add a todo_website/__init__.py file with the following line:
from . import controllers
  1. Then, add a todo_website/controllers/__init__.py file with the following line:
from . import main
  1. Now, add the actual file for the controller, todo_website/controllers/main.py, with the following code:
from odoo import http 
 
class Todo(http.Controller): 
 
    @http.route('/helloworld', auth='public') 
    def hello_world(self): 
        return('<h1>Hello World!</h1>') 

The odoo.http module provides the Odoo web-related features. Our controllers, responsible for page rendering, should be objects inheriting from the odoo.http.Controller ...

Get Odoo 11 Development Essentials - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.