Skip to content
This repository has been archived by the owner on Oct 26, 2023. It is now read-only.

Commit

Permalink
Added new library to init script and refactored code
Browse files Browse the repository at this point in the history
  • Loading branch information
rtrevinnoc committed Feb 7, 2021
1 parent 6633d5b commit 20bfc69
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
1 change: 1 addition & 0 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pip3 install -U h5py
pip3 install -U uWSGI
pip3 install -U wordnet
pip3 install -U numexpr
pip3 install -U flask-caching

python3 -m spacy download en_core_web_sm
python3 -c "import nltk; nltk.download('punkt')"
Expand Down
20 changes: 11 additions & 9 deletions future.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@
spellChecker.load_dictionary(
"./frequency_dictionary_en_82_765.txt", 0, 1
) # LAST TWO PARAMETERS ARE (COLUMN TERM, FREQUENCY TERM) LOCATIONS IN DICTIONARY FILE
cache = Cache(app, config={'CACHE_TYPE': 'filesystem','CACHE_DEFAULT_TIMEOUT': CACHE_TIMEOUT, 'CACHE_THRESHOLD': CACHE_THRESHOLD, 'CACHE_DIR': './external_image_cache'})
cache = Cache(app,
config={
'CACHE_TYPE': 'filesystem',
'CACHE_DEFAULT_TIMEOUT': CACHE_TIMEOUT,
'CACHE_THRESHOLD': CACHE_THRESHOLD,
'CACHE_DIR': './external_image_cache'
})


def sendRegisterRequestToPeer(url):
Expand Down Expand Up @@ -143,9 +149,7 @@ def sendAnswerRequestToPeer(url, query, queryVector, queryLanguage,
timeout=10)
result = r.json()["result"]
print("Obtained with http")
return {
"urls": list(zip(result["urls"], result["url_scores"]))
}
return {"urls": list(zip(result["urls"], result["url_scores"]))}
except:
try:
r = requests.get("https://" + peer + "/_answerPeer",
Expand Down Expand Up @@ -899,6 +903,7 @@ def _updateAnswer():
for item in bigListOfUrls}.values())
})


@app.route("/_updateImages", methods=["GET", "POST"])
def _updateImages():
query = request.args.get("query", 0, type=str)
Expand All @@ -924,11 +929,8 @@ def _updateImages():
else:
bigListOfImages = images["images"]

return jsonify(
result={
"images":
bigListOfImages
})
return jsonify(result={"images": bigListOfImages})


@app.route("/_midnightcypher")
def _midnightcypher():
Expand Down

0 comments on commit 20bfc69

Please sign in to comment.