I've searched this subject already for a bit on the Internet and I couldn't find anything decent:
I was wondering if it possible to call a single Python function from a Python file from JavaScript?
I already came across suggestions such as $ajax-requests, (Call Python function from Javascript code) but this only seems to execute the __main__
method of said Python file. Other suggestions I came across also just execute the entire Python file, without the possibility of just executing a single method of it.
What I want is for example a Python-class containing methods this:
def testMethod(self):
print "testMethod called from JavaScript"
return "It worked!"
and that I would be able to call this testMethod()
from JavaScript (optionally with parameters etc. of course if the method expects them).
Is this possible in a simple way? I mention the word simple because frameworks like Flask etc. would be my last resort, I'd much more prefer something fast and doesn't change my webproject too much for the rest.