Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
3964 Zobrazení

Hi, do you have some examples how to get the data from a python method in a controller using javascript?

.py

@http.route('/saas/createdb', type='json', auth="public", methods=["POST"], website=True)
    def createdb(self, db_name):
        
        session = self._authenticate()
        if not session:
            return json.dumps(False)
        # create a new database
        headers = {'Content-Type': 'application/json'}
        
        create_db_url = "http://localhost:8090/saas_api/create_db"
        data = {"jsonrpc": 2.0, "params": { "name": db_name } } // how to get this?
        _logger.debug("Creating database...")
        r = session.post(url=create_db_url, data=json.dumps(data), headers=headers)
        if r.ok:
            return json.dumps(True)
        else:
            return json.dumps(False)

.js

var db_name = $('input').attr('contact_name');
session.rpc('/saas/createdb', { db_name: db_name }).then(function (result){ //result }



Error:
TypeError: createdb() takes exactly 2 arguments (1 given)\n","exception_type":"internal_error","message":"createdb() takes exactly 2 arguments (1 given)","name":"exceptions.TypeError","arguments":["createdb() takes exactly 2 arguments (1 given)"]}}
Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
7
led 24
51974
2
říj 20
4171
2
bře 15
1110
1
led 20
9735
0
dub 17
3527