Third party python libraries

First,
let’s face it: we’re dealing with a very good framework.
Second,
In no way am I experienced enough to deal with all of it’s abillities.

:pleading_face:
SO!

I really need help with an idea I been playing with, but can’t figure out how to do.
The thing is, it requires me implementing a python function. This function requires different libraries loaded in order to work (e.g. requests).
As I understand I need a whitelist function (not sure, but stay with me here…)
So let’s say I created a DocType named Test and it needs the python function, which requires the requests library imported how do I do this?

I will try to be more specific
I want to create a new file:
~/frappe-bench/apps/my_app/my_app/my_app/doctype/test/test_fun.py
inside I want it to have the following code:

import requests

def func(some_string)
 r = requests.get(some_string, some_args)`
return r.text

and then I want to be able to have a client script that performs:

...
frm.call('func', {'some_string': 'string'} 
.then(r => {
        if (r) {
            let data = r;
            // do something with data
        }
    })

Is it at all possible?

Anyone?
:pleading_face:

https://frappeframework.com/docs/user/en/guides/basics/frappe_ajax_call

1 Like

thanks I’ll try this

tried a simple script:

@frappe.whitelist()
def test():
        return 'Success!'


and got:

Failed to get method for command path.to.doctype.doctype_name.py_file_name.test with name ‘frappe’ is not defined

:roll_eyes:

import frappe
2 Likes

Thanks! :slight_smile:
:man_facepalming: