Last active
November 15, 2019 16:23
-
-
Save berserker1/eea94dc56899f136b584a220ab4a5ef9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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