I am creating a controller in the OpenERP Framework. Below is my code and I am installing http.route type="http",
import openerp.http as http
from openerp.http import request
class MyController(http.Controller):
@http.route('demo_html', type="http")
def some_html(self):
return "<h1>This is a test</h1>"
Excellent work on the code after I enter openerp after I changed the URL http://localhost:8069/demo_html, show me the result of the return This is a testin the h1 header tag.
But I also try to type="json"add the following json code and try to call the URL again. http://localhost:8069/demo_jsonIt does not work correctly and will show me an error "Internal Server Error".
import openerp.http as http
from openerp.http import request
class MyController(http.Controller):
@http.route('demo_html', type="http") // Work Pefrect when I call this URL
def some_html(self):
return "<h1>This is a test</h1>"
@http.route('demo_json', type="json") // Not working when I call this URL
def some_json(self):
return {"sample_dictionary": "This is a sample JSON dictionary"}
So my question is how to direct json. Any help would be appreciated Thanks.
source
share