title: Run a Python Script from the Web
body: <p>I've been stumbling along with the same problem for almost a year now. I always find a way to work around it, but I'm tired of finding work arounds.</p>
  
  <p>What I need is to create a button on a Web Page (preferable HTML, not PHP or ASP) that runs a python script on the server. I'd also like the ability to have this button send information from a form to the script.</p>
  
  <p>I need to do this on a local host and through a web service hosted on the Amazon Cloud. I won't be able to install anything extra on the Amazon Cloud service, such as PHP or CGI. </p>
  
  <p>I'd really like an easy solution, I'm an expert with python and I can write webpages that whistle, but I just can't find a simple solution to this problem.</p>
  
  <p>My ideal solution would be something like the mail to tag:</p>
  
  <pre><code>&lt;a href="mailto:someone@example.com?Subject=Hello%20again"&gt;Send Mail&lt;/a&gt;
  </code></pre>
  
  <p>Except:</p>
  
  <pre><code>&lt;a href="myscript.py?Subject=1234"&gt;Run Script&lt;/a&gt;
  </code></pre>
  
  <p>Now I highly doubt a solution like that exists, but well I can dream right.</p>
  
  <p>The script I am trying to run:</p>
  
  <ol>
  <li>Returns a Unique ID from the user</li>
  <li>Sends the ID to a GIS program that creates a map based on the ID (the ID selects the area of the map)</li>
  <li>The map is then exported to a PNG, wrote into an HTML document and then displayed for the user in a new tab.</li>
  </ol>
  
  <p>EDIT ---------------------------</p>
  
  <p>Thanks to @Ketouem answer I was able to find a great solution to my issue. I'll post some of the code here so that others can benefit. Make sure you download the Bottle Module for python, its great.</p>
  
  <pre><code># 01 - Import System Modules
  from bottle import get, post, request, Bottle, run, template
  
  # 02 - Script Variables
  app = Bottle()
  
  # 03 - Build Temporary Webpage
  @app.route('/SLR')
  def login_form():
      return '''&lt;form method="POST" action="/SLR"&gt;
                  Parcel Fabric ID: &lt;input name="UID" type="text" /&gt;&lt;br /&gt;
                  Save Location: &lt;input name="SaveLocation" type="text" value="D:/Python27/BottleTest/SLR_TestOutputs"/&gt;&lt;br /&gt;
                  Air Photo On: &lt;input name="AirPhoto" type="checkbox"/&gt;&lt;br /&gt;                
                  Open on Completion: &lt;input name="Open" type="checkbox"/&gt;&lt;br /&gt;
                  Scale: &lt;input name="Scale" type="text" value="10000"/&gt;&lt;br /&gt;
                  &lt;input type="submit" /&gt;
                &lt;/form&gt;'''
  
  # 04 - Return to GIS App
  @app.route('/SLR', method='POST')
  def PHPH_SLR_Script():
      # I won't bother adding the GIS Section of the code, but at this point it send the variables to a program that makes a map. This map then saves as an XML and opens up in a new tab.
  
   # 04 - Create and Run Page
  run(app, host='localhost', port=8080)
  </code></pre>