Browse Source

refactoring

master
wes 8 years ago
parent
commit
be93c967c6
  1. 2
      src/search.py
  2. 22
      src/website.py

2
src/search.py

@ -161,7 +161,7 @@ def filterSections(secs):
return filtered
return False
def searchTerms(terms):
def search_courses(terms):
"""
Run a search for courses
"""

22
src/website.py

@ -1,25 +1,19 @@
#! /usr/bin/python3
from functools import partial
from urllib.parse import quote, unquote
from json import loads
from flask import Blueprint, abort, Flask, render_template, flash, request, send_from_directory, jsonify
from flask_bootstrap import Bootstrap
from flask_appconfig import AppConfig
from werkzeug.contrib.cache import MemcachedCache
from search import searchTerms
from search import search_courses
from openlibrary import bookUrls
from syslog import syslog
from archive import searchIA
from urllib.parse import quote, unquote
from json import loads
from werkzeug.contrib.cache import MemcachedCache
cache = MemcachedCache(['127.0.0.1:11211'])
import os
def predict(fieldtype, term):
print(fieldtype)
print(term)
@ -75,7 +69,7 @@ def ClassSearch(configfile=None):
for key, val in params.items():
if val in defaults:
del params[key]
return jsonify(searchTerms(params))
return jsonify(search_courses(params))
@blueprint.route("/resources", methods=("GET", "POST"))
def resources():
@ -84,14 +78,14 @@ def ClassSearch(configfile=None):
try:
params = loads(unquote(dict(request.args.items())["data"]))
except KeyError:
return jsonify("false")
return jsonify(False)
print(params)
author = params["author"]
title = params["title"]
if ("No Textbooks" in title or
"No Adoption" in title):
return jsonify("false")
return jsonify(False)
# Cache the result of the open library search
openlib = cacheit("openlib"+title+author, lambda : bookUrls(title, author))
@ -103,7 +97,7 @@ def ClassSearch(configfile=None):
if not (any(openlib) or any(iarchive)):
# We literally could not find ANYTHING
return jsonify("false")
return jsonify(False)
return jsonify({
"iarchive" : iarchive,

Loading…
Cancel
Save