Skip to content

Commit 740d47d

Browse files
author
Joe Kohlmann
committed
Updated the config example and modified the Flask app to correctly update its in-memory copy of the saved queries.
1 parent 47356e3 commit 740d47d

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

flask/app.py

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ def write_query_to_cache(query, queries):
1818
queries.insert(0, query)
1919
if app.config["DEBUG"]:
2020
print "Adding %s to list of cached queries." % query
21+
else:
22+
print "Returning early since cached queries list is up-to-date on disk."
23+
return
2124
# Write everything back. Yes, this is inefficient.
2225
input_file = codecs.open(cache_path, encoding="utf-8", mode="w")
2326
json.dump(queries, input_file)

flask/config_example.py

+13
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@ class Config(object):
77
# NYT Article Search API Key
88
# Request a key at http://developer.nytimes.com
99
SEARCH_API_KEY = "PASTE_API_KEY_HERE"
10+
CACHE_ROOT = os.path.join(
11+
os.path.dirname(os.path.realpath(__file__)),
12+
"static",
13+
"cache"
14+
)
15+
ARTICLE_SEARCH_ROOT = os.path.join(
16+
CACHE_ROOT,
17+
"ArticleSearch"
18+
)
19+
QUERY_CACHE_PATH = os.path.join(
20+
CACHE_ROOT,
21+
"queries.json"
22+
)
1023

1124

1225
class DevelopmentConfig(Config):

flask/static/cache/queries.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
["persons:(\"JOBS, STEVEN P\") OR persons:(\"Jobs, Steve\")", "organizations:(\"Twitter\")", "subject:(\"Whistle-Blowers\")", "persons:(\"Manning, Bradley E\")", "organizations:(\"MICROSOFT CORP\") OR organizations:(\"Microsoft Corporation\")", "persons:(\"Bell, Kristen\")", "creative_works:(\"Veronica Mars (TV Program)\") OR creative_works:(\"Veronica Mars (Movie)\")", "organizations:(\"KICKSTARTER\") OR organizations:(\"KICKSTARTER.COM\")", "organizations:(\"Facebook Inc\") OR organizations:(\"FACEBOOK.COM\")", "organizations:(\"Google Inc\")", "subject:(\"Wearable Computing\")", "persons:(\"Putin, Vladimir V\")", "organizations:(\"APPLE COMPUTER INC\") OR organizations:(\"APPLE INC\")", "subject:(\"Patient Protection and Affordable Care Act (2010)\")", "organizations:(\"University of Washington\")", "organizations:(\"University of Wisconsin-Madison\")", "organizations:(\"National Security Agency\")", "organizations:(\"WIKILEAKS\")", "persons:(\"Snowden, Edward J\")", "persons:(\"Assange, Julian\")", "glocations.contains:(\"Seattle\")", "glocations.contains:(\"Madison\")", "persons:(\"Obama, Barack\")", "subject:(\"Super Bowl\")", "organizations:(\"HARVARD UNIVERSITY\")"]
1+
["persons:(\"Christie, Christopher J\")", "persons:(\"Walker, Scott K\")", "glocations:(\"Madison (Wis)\")", "persons:(\"JOBS, STEVEN P\") OR persons:(\"Jobs, Steve\")", "organizations:(\"Twitter\")", "subject:(\"Whistle-Blowers\")", "persons:(\"Manning, Bradley E\")", "organizations:(\"MICROSOFT CORP\") OR organizations:(\"Microsoft Corporation\")", "persons:(\"Bell, Kristen\")", "creative_works:(\"Veronica Mars (TV Program)\") OR creative_works:(\"Veronica Mars (Movie)\")", "organizations:(\"KICKSTARTER\") OR organizations:(\"KICKSTARTER.COM\")", "organizations:(\"Facebook Inc\") OR organizations:(\"FACEBOOK.COM\")", "organizations:(\"Google Inc\")", "subject:(\"Wearable Computing\")", "persons:(\"Putin, Vladimir V\")", "organizations:(\"APPLE COMPUTER INC\") OR organizations:(\"APPLE INC\")", "subject:(\"Patient Protection and Affordable Care Act (2010)\")", "organizations:(\"University of Washington\")", "organizations:(\"University of Wisconsin-Madison\")", "organizations:(\"National Security Agency\")", "organizations:(\"WIKILEAKS\")", "persons:(\"Snowden, Edward J\")", "persons:(\"Assange, Julian\")", "glocations.contains:(\"Seattle\")", "glocations.contains:(\"Madison\")", "persons:(\"Obama, Barack\")", "subject:(\"Super Bowl\")", "organizations:(\"HARVARD UNIVERSITY\")"]

0 commit comments

Comments
 (0)