Added to API where results show from title

pull/2/head
tmitche2 2020-02-05 11:24:42 -05:00
parent 95e44300f0
commit 4da48998fb
2 changed files with 13 additions and 10 deletions

View File

@ -12,25 +12,28 @@ bp = Blueprint('search', __name__)
@bp.route('/')
def index():
results = None
term = None
title = None
paging=None
search_type = "ft"
print("TEST HERE")
print(request.args)
print(request.args.get("title"))
print(request.method)
print("DONE PRINTING")
title = request.form.get('title')
print(title)
print("----------------------------------------------------------")
if request.args:
term = request.args['title']
response = search(request.args['type'], request.args.get('page'),
if request.args.get("title"):
title = request.args['title']
response = search(request.args['title'], request.args.get('page'),
request.args.get('per_page'))
paging = proc_pagination(response['data']['paging'],
request.args.get('page'))
results = proc_results(response)
print(results)
return render_template('base.html', title=title)
@ -41,7 +44,7 @@ def proc_results(r):
def enhance_results(r):
if r.get('type') == 'renewal':
if r.get('title') == 'renewal':
return r
return {**r, **{'original': strip_tags(r.get('xml')),

View File

@ -52,11 +52,11 @@
<p>Search for copyright registrations and renewals on books from the Catalog of Copyright Entries.</p>
<p>Find a book:</p>
<form>
<input type="text" name="title" id="title" placeholder="Title"><br>
<input type="text" name="author" placeholder="Author"><br>
<input type="text" name="publisher" placeholder="Publisher"><br>
<input type="text" name="registration" placeholder="Registration Number"><br>
<input type="text" name="renewal" placeholder="Renewal Number"><br>
<input type="text" name="title" id="title" placeholder="Title" autocomplete="off"><br>
<input type="text" name="author" placeholder="Author" autocomplete="off"><br>
<input type="text" name="publisher" placeholder="Publisher" autocomplete="off"><br>
<input type="text" name="registration" placeholder="Registration Number" autocomplete="off"><br>
<input type="text" name="renewal" placeholder="Renewal Number" autocomplete="off"><br>
<input type="submit" value="Search" class="btn">
</form>
</div>