Skip to content

Instantly share code, notes, and snippets.

@berserker1
Last active November 15, 2019 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save berserker1/eea94dc56899f136b584a220ab4a5ef9 to your computer and use it in GitHub Desktop.
Save berserker1/eea94dc56899f136b584a220ab4a5ef9 to your computer and use it in GitHub Desktop.
from flask import Flask, render_template
# from db_setup import init_db, db_session
from forms import MusicSearchForm
from flask import flash, request, redirect, url_for
import requests
from query import do_query
# from models import Album
app = Flask(__name__)
@app.route("/", methods=["GET", "POST"])
def index():
return render_template("index.html")
@app.route("/about", methods=["GET", "POST"])
def about():
return render_template("about2.html")
@app.route("/result_page/<result>", methods=["GET", "POST"])
def result_page(result):
print('Request is shit', request)
return render_template('result.html', result=result)
@app.route("/adder_page", methods=["GET", "POST"])
def adder_page():
errors = ""
result = None
print('it')
print('rEQUEST IS', request)
if request.method == "POST":
# print('chala')
print(request)
question = None
print(1)
try:
question = request.form['question']
print(question)
# question = str(question[2:])
# question = question.replace("+", " ")
except Exception:
errors += "<p>{!r} is not a query_string.</p>\n"
print("EXCEPTION OCCURRED!!!!!!!!!\n")
print(Exception)
if question is not None:
print(question[2:-1])
result = '343'
# result = do_query(question[2:-1])
print(result)
return redirect(url_for('result_page', result=result))
# return '''
# <html>
# <body>
# {errors}
# <p>Enter your query:</p>
# <form method="post" action="""{{ url_for('result_page', result={res}) }}""">
# <p><input name="Query" /></p>
# <p><input type="submit" value="Search" /></p>
# </form>
# </body>
# </html>
# '''.format(errors=errors,res=result)
return render_template('adder_pg.html', errors=errors, result=result)
if __name__ == "__main__":
app.run(debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment