Splunk Dev

Python end point configured in web.conf is not working

paramagurukarth
Builder

I am just trying to make a python method to respond for a http request (Interact with python using javascript).
I got an url from splunk wiki
The configuration given in that url is
1. Create an app with my python module inside controllers folder
2. In web.conf create a endpoint as [endpoint:]
3. just restart. The method inside the puython module can be accessed through the url
./custom///
4. Restart and login again

But, even after doing the above configuration URL of the above pattern is not available.
Anyone Please share your knoledge related to this.

Thanks.

1 Solution

paramagurukarth
Builder

Sorry.. Same set up works for me...
Previously I just configured the web.conf in $Splunk_Home$/etc/system/local..
Now I did the same configuration inside $Splunk_Home$/etc/apps//default. It works and my python function is working as a listener for a http request (http:/ip:/custom///)

web.conf :
[endpoint:netutils] #Name of the python file

netutils.py
import cherrypy
import splunk.appserver.mrsparkle.controllers as controllers
from splunk.appserver.mrsparkle.lib.decorators import expose_page
from splunk.appserver.mrsparkle.lib.routes import route

class MyControllerController(controllers.BaseController):
@expose_page(must_login=True)
def listenerGet(self, **kwargs):
cherrypy.response.headers['Content-Type'] = 'text/plain'
return 'I am responding for your request'

Please refer http://wiki.splunk.com/Community:40GUIDevelopment

View solution in original post

paramagurukarth
Builder

Sorry.. Same set up works for me...
Previously I just configured the web.conf in $Splunk_Home$/etc/system/local..
Now I did the same configuration inside $Splunk_Home$/etc/apps//default. It works and my python function is working as a listener for a http request (http:/ip:/custom///)

web.conf :
[endpoint:netutils] #Name of the python file

netutils.py
import cherrypy
import splunk.appserver.mrsparkle.controllers as controllers
from splunk.appserver.mrsparkle.lib.decorators import expose_page
from splunk.appserver.mrsparkle.lib.routes import route

class MyControllerController(controllers.BaseController):
@expose_page(must_login=True)
def listenerGet(self, **kwargs):
cherrypy.response.headers['Content-Type'] = 'text/plain'
return 'I am responding for your request'

Please refer http://wiki.splunk.com/Community:40GUIDevelopment

amritanshgupta
Explorer

I can't get this to work. Is it not supported in 6.4.x and above?
The documentation you've linked to in another answer is of Splunk 4.x
I always get a error 404, even when I tried to run your exact code. Anyway I can fix this?

Thanks

0 Karma

kasu_praveen
Communicator

Hi paramagurukarthikeyan, Thanks for posting this. I am also looking similar one like this.
couple of clarifications.

1, How you called "MyPython.py" in your HTML view page?
2. You mentioned endpoint as "netutils", But where are you using this?, I am not seeing this in .py file.

Thanks for your time.

0 Karma

paramagurukarth
Builder
0 Karma

kasu_praveen
Communicator

Got answers for my above questions in another thread link text. Thanks

0 Karma

paramagurukarth
Builder

Sorry, I couldn't help you.. I just saw 🙂

0 Karma
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...

Updated Data Management and AWS GDI Inventory in Splunk Observability

We’re making some changes to Data Management and Infrastructure Inventory for AWS. The Data Management page, ...