<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Create a HTML form that post to a python script in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Create-a-HTML-form-that-post-to-a-python-script/m-p/144143#M2003</link>
    <description>&lt;P&gt;I have a html page with a form and want the the form to submit to a python script.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Questions:&lt;/STRONG&gt;&lt;BR /&gt;
Where under a custom app would you place the python script?&lt;BR /&gt;
What url would I put in the form action to hit the script?  &lt;/P&gt;</description>
    <pubDate>Sun, 07 Jun 2015 20:12:20 GMT</pubDate>
    <dc:creator>splunkcvc</dc:creator>
    <dc:date>2015-06-07T20:12:20Z</dc:date>
    <item>
      <title>Create a HTML form that post to a python script</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Create-a-HTML-form-that-post-to-a-python-script/m-p/144143#M2003</link>
      <description>&lt;P&gt;I have a html page with a form and want the the form to submit to a python script.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Questions:&lt;/STRONG&gt;&lt;BR /&gt;
Where under a custom app would you place the python script?&lt;BR /&gt;
What url would I put in the form action to hit the script?  &lt;/P&gt;</description>
      <pubDate>Sun, 07 Jun 2015 20:12:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Create-a-HTML-form-that-post-to-a-python-script/m-p/144143#M2003</guid>
      <dc:creator>splunkcvc</dc:creator>
      <dc:date>2015-06-07T20:12:20Z</dc:date>
    </item>
    <item>
      <title>Re: Create a HTML form that post to a python script</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Create-a-HTML-form-that-post-to-a-python-script/m-p/144144#M2004</link>
      <description>&lt;P&gt;I would use a SplunkWeb controller for this. Here is how you would make it:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Step 1: Make the controller binary&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Make an executable in the app under the path: $SPLUNK_HOME/etc/apps//appserver/controllers/. If your controller was called my_custom_controller, it would be under: $SPLUNK_HOME/etc/apps/appserver/controllers/my_custom_controller.py.&lt;/P&gt;

&lt;P&gt;See the following example of a Splunk controller: &lt;A href="https://github.com/LukeMurphey/splunk-web-input/blob/master/src/appserver/controllers/web_input_controller.py" target="_blank"&gt;https://github.com/LukeMurphey/splunk-web-input/blob/master/src/appserver/controllers/web_input_controller.py&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Step 2: Expose the controller&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Make a web.conf in the app under the path: $SPLUNK_HOME/etc/apps//default/web.conf. Add a line to this file that exposes your controller. Below is an example (assuming your controller is named called my_custom_controller.py):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[endpoint:my_custom_controller]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Restart Splunk for the controller to be visible. You can verify that your controller is recognized by navigating to /paths with your browser (e.g. &lt;A href="http://mysplunkserver/paths" target="_blank"&gt;http://mysplunkserver/paths&lt;/A&gt;); your controller should be listed if this worked (just search for your controller name, e.g. "my_custom_controller").&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Step 3: Wire-up your HTML form&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Your controller will be exposed under the path /custom//my_custom_controller. For example, if you declared a function called "do_something" within your controller called "my_custom_controller" which is included the in the "my_app" app, then you could access that function from an HTML form with the URL "/custom/my_app/my_custom_controller/do_something").&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 20:11:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Create-a-HTML-form-that-post-to-a-python-script/m-p/144144#M2004</guid>
      <dc:creator>LukeMurphey</dc:creator>
      <dc:date>2020-09-28T20:11:41Z</dc:date>
    </item>
  </channel>
</rss>

