Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
3473 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
49607
2
říj 20
3769
2
bře 15
658
1
led 20
9184
0
dub 17
3048