Add cache for non-item content
This commit is contained in:
parent
814de5f094
commit
78c3f44735
3
.gitignore
vendored
3
.gitignore
vendored
@ -126,6 +126,7 @@ dmypy.json
|
||||
# Praw files
|
||||
praw.ini
|
||||
|
||||
# Inquisitor scratch directory
|
||||
# Inquisitor directories
|
||||
dungeon/
|
||||
cache/
|
||||
|
||||
|
@ -4,10 +4,10 @@ import os
|
||||
import traceback
|
||||
|
||||
# Third party imports
|
||||
from flask import Flask, render_template, request, jsonify
|
||||
from flask import Flask, render_template, request, jsonify, abort
|
||||
|
||||
# Application imports
|
||||
from inquisitor.configs import logger, DUNGEON_PATH
|
||||
from inquisitor.configs import logger, DUNGEON_PATH, CACHE_PATH
|
||||
from inquisitor import sources, loader, timestamp
|
||||
|
||||
# Globals
|
||||
@ -145,3 +145,11 @@ def callback():
|
||||
logger.error("Bad request params: {}".format(params))
|
||||
sources.item_callback(params['source'], params['itemid'])
|
||||
return jsonify({})
|
||||
|
||||
@app.route('/cache/<path:cache_path>')
|
||||
def cache(cache_path):
|
||||
path = os.path.join(CACHE_PATH, cache_path)
|
||||
if not os.path.isfile(path):
|
||||
return abort(404)
|
||||
with open(path, 'rb') as f:
|
||||
return f.read()
|
||||
|
@ -3,6 +3,7 @@ import logging
|
||||
|
||||
DUNGEON_PATH = os.path.abspath(os.environ.get("INQUISITOR_DUNGEON") or "./dungeon")
|
||||
SOURCES_PATH = os.path.abspath(os.environ.get("INQUISITOR_SOURCES") or "./sources")
|
||||
CACHE_PATH = os.path.abspath(os.environ.get("INQUISITOR_CACHE") or "./cache")
|
||||
|
||||
logger = logging.getLogger("inquisitor")
|
||||
handler = logging.StreamHandler()
|
||||
|
Loading…
Reference in New Issue
Block a user