我使用瓶子为 openerp 创建了一个 api
使用浏览器访问时效果很好
我不知道如何将它作为 json 参数传递
问题是
我如何使用 api 调用并传递 json 参数,例如
http://localhost/api?name=admin&password=admin&submit=Submit
这是我的 wsgi 代码 app.wsgi
import json
import os
import sys
import bottle
from bottle import get, post, run,request,error,route,template,validate,debug
def login():
import xmlrpclib
username = request.forms.get('name')
pwd = request.forms.get('password')
dbname = 'more'
sock_common = xmlrpclib.ServerProxy ('http://localhost:8069/xmlrpc/common')
uid = sock_common.login(dbname, username, pwd)
if uid:
return json.dumps({'Success' : 'Login Sucessful'])
def index():
return '''
<html>
<head>
<title> Portal</title>
</head>
<body>Welcome To PORTAL
<form method="GET" action="/api/links" enctype="multipart/form-data">
Name:<input name="name" type="text"/><br>
Password:<input name="password" type="password"/><br>
<input type="submit" value="Submit" name="submit">
</form>
</body>
</html>'''
def links():
return '''
<html>
<head>
<title> Portal</title>
</head>
<body>
<a href="/api/advisor">Advisor<br>
</body>
</html>'''
application = bottle.default_app()
application.route('/', method="GET", callback=index)
application.route('/', method="POST",callback=login)