How do I execute a Python script based off user inputed fields from a Website
<p>Using the following python.py file below as an example, how could a user on a website form select the position from something like a dropdown field or the user could input WR, RB, QB themselves. (position="WR" is currently what is in the code below) and click submit and the code will execute the query into a table?</p>

<p>I am using Wordpress on one server with MySQL.  On another server, I am using Python and PostgreSQL.  Thank you for any help you can provide.</p>

<pre><code>import nfldb

db = nfldb.connect() q = nfldb.Query(db) q.game(season_year=2015, season_type='Regular') 
q.player(position="WR") 
q.play(receiving_rec=1)

def inside(field, stat):
        cutoff = nfldb.FieldPosition.from_str(field)
        return lambda play: play.yardline + getattr(play, stat) &gt;= cutoff plays = filter(inside('OPP 20', 'receiving_yds'), q.as_plays())

for p in plays:
   print p
</code></pre>

<p>I'm no expert, but be able to run code in response to any user interaction on your website, there should be some kind of web service running that would run your code.
The general idea would be to first have the Wordpress server able to send out a "GET" to your postgre server, and be able to receive its answer.
Then I would create a Web Service on your PostgreSQL (something like <a href="http://flask.pocoo.org/" rel="nofollow">Flask</a> would be just fine, if you want you have the excellent tutorial by <a href="http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world" rel="nofollow">Miguel Grinberg</a>) so it can receive the request, run the code you mention and then send the response to the Wordpress+MySQL.</p>

<p>Hope I'm pointing you in the right direction.</p>

php python sql wordpress postgresql