Where to configure the Controller for the New Page?

Hello, when creating a new Page, we get page/custom_page.json and page/custom_page.js for the boilerplate. I was curious where can I get the controller for this page so I can customize the data I want to send to this page and other data operations on the backend if we can get something like page/custom_page.py file in it to control this new Page.

Any suggestions, help on this one?

HI @Abhiraj_Tulsyan:

You can create your custom_page.py file and there add your get_context method.
Actually, from .js file you can call any method over the framework.

See how backups page is made:

Hope this helps.

1 Like

Hello there,
“We can call any method from js”, by this you mean calling through frappe.call method right?

@Abhiraj_Tulsyan: Yes!

I mean we can only call after authenticating the user in Frappe.call right? or how will API get called?

Hi @Abhiraj_Tulsyan:

Pages (no webpages) are shown to authenticated users. So it wil be no needed auth in frappe.call

Okay, but what if I want to show to specific customers only?
So when we create Page do we have any role / permission level to that?

Yes, at page creation you can restrict it to specific roles.

Hmm okay, and so If we do frappe call from the client side, who is not in the specific allowed role of that Page, we will get error by default using Frappe call. So anyway of handling that smoothly in the framework or we have to write custom code only in respective called(server side) function?

Hi @Abhiraj_Tulsyan:

Actually, your page will be not showed to an user without the proper role, so there will be not calls from client side.

Anyway, you can implement your own permission logic on backend if you need it.
Hope this helps.