How to run python script from website javascrpit

I am trying to create custom python and javascript but would like to know where to insert it in frappe or erpnext.

When a client or future client or anyone goes to our website I would like to take that from javascript and push through python to do a backend command. I know decent python and some javascript and know to white list and allow for guests but I do not know where to place it here. I read that you need to put in a web form and doctype but where would you put in the python api to push to the server to do a command

I am doing several things for both the actual website business and also just to be a nerd and develop.


You can’t write any python code directly from website.
To write customize python code you’ve to create new custom app and place your python code inside custom app then call it using whitelisted function & method.

Ref link to create new app:

Here’s simplest example code.

In HTML file

	frappe.ready(function() {
		$('#send').off("click").on("click", function() {{
				method: "",
				callback: function(r) {

			return false;


In under custom_app/custom_app

import frappe

def yyy():

	print("Hello Python")

	return "okay"

Does frappe allow you to write a custom app? Or do you have to write it raw?

You’ve to create new-app first.

To your answer, Thats, my hold up I think as of yet. Where do you place the python at in the custom app? do you place it in a new doctype because I do not see a place to put it. Or do you put it in the system files under the customAPP?

If you follow the tutorial you should place your python in library_management/library_management/
Does that answer your question?

1 Like

hi ,
can you please tell me what is #send
your button name in webform or something else
frappe.ready(function() {
$(‘#send’).off(“click”).on(“click”, function() {
#send means??{
method: “”,
callback: function(r) {

$ is syntax for jQuery library.
#send is a selector # is for select element by id.

So in this case $('#send') here means select element that have send as an id.

For more detail you can check out jQuery selector docs.

1 Like

Thank you so much for the reference you shared
Basically, I want to allow my guest users to resubmit the same old web form where the phone number field is unique I was looking if we can update the user record via web form using the PUT rest API please let me know your valuable opinion on this.
Thank you

how did you manage to edit the HTML to add id (send) i could not find any id on my webform

You don’t necessarily need $('#send'). This is just one way to identify specific elements. In your case, you could use something like $('.btn-primary'). You can check the jQuery docs for more details.


great advice thank you so much for taking some time and helping out me