Skip to content

Instantly share code, notes, and snippets.

@lakshay-arora
Created April 28, 2020 08:19
Show Gist options
  • Save lakshay-arora/b9f9bb56e1dc26a60e616af323595672 to your computer and use it in GitHub Desktop.
Save lakshay-arora/b9f9bb56e1dc26a60e616af323595672 to your computer and use it in GitHub Desktop.
# start flask
app = Flask(__name__)
# render default webpage
@app.route('/')
def home():
return render_template('home.html')
# when the post method detect, then redirect to success function
@app.route('/', methods=['POST', 'GET'])
def get_data():
if request.method == 'POST':
user = request.form['search']
return redirect(url_for('success', name=user))
# get the data for the requested query
@app.route('/success/<name>')
def success(name):
return "<xmp>" + str(requestResults(name)) + " </xmp> "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment