.
from flask import Flask, render_template, request
from flask_mysqldb import MySQL
import yaml
from subprocess import Popen, PIPE
from threading import Thread
import time
import subprocess
app = Flask(__name__)
db = yaml.full_load(open('db.yaml'))
app.config['MYSQL_HOST'] = 'xxx'
app.config["MYSQL_USER"] = "xxx"
app.config["MYSQL_PASSWORD"] = "xxx"
app.config["MYSQL_DB"] = "xxx"
mysql = MySQL(app)
@app.route("/", methods=["GET", "POST"])
def index():
if request.method =="POST":
#fetch form data
userDetails=request.form
title=userDetails["title"]
location=userDetails["location"]
radius=userDetails["radius"]
email=userDetails["email"]
cur = mysql.connection.cursor()
cur.execute("INSERT INTO requests(title, location, radius, email) VALUES(%s, %s, %s, %s)", (title, location, radius, email))
mysql.connection.commit()
cur.close()
subprocess.Popen(['python', 'crawler.py'])
return render_template('donenew.html')
return render_template("indexnew.html")
if __name__ == "__main__":
app.run(debug=True)