OpenERP Framework でコントローラーを作成しています。以下は私のコードで、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>"
上記のコードは、URL を変更した後に openerp にログインすると完全に機能し、http://localhost:8069/demo_html
結果This is a test
が h1 見出しタグで返されることが示されます。
しかし、同じようにtype="json"
、次のjsonコードを追加しようとして、もう一度URLを呼び出そうとしますhttp://localhost:8069/demo_json
が、正しく機能せず、エラーが表示されます"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"}
だから私の質問はjson をルーティングする方法です。どんな助けでも感謝しますありがとう。