aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormjfernez <mjf@mjfer.net>2022-02-25 17:36:01 -0500
committermjfernez <mjf@mjfer.net>2022-02-25 17:36:01 -0500
commit5589754533aab9b7edbdc41cc13c2cd189aa3c26 (patch)
tree8e8b6ace47e4233eb807d8f0eec7ea7ad3dab73f
parent43e114b82500476fa81754bf099ad25ee945201e (diff)
downloadezcms-5589754533aab9b7edbdc41cc13c2cd189aa3c26.tar.gz
Remove flask caching and unused imports
This removes Flask caching since it seems I'm dumb and can't implement it correctly and it seems to serve pretty much no purpose anyway. Caching can always be handled by the server in front This commit also removes some unused imports that were leftover after moving functionality to different files (like view_functions) Flask compress might be useless too since nginx can also gzip. But I can actually observe the change... is there any problem with double gzipping?
-rw-r--r--README.md6
-rw-r--r--requirements.txt1
-rw-r--r--rss_generator.py4
-rw-r--r--server.py5
-rw-r--r--siteconfig.py29
-rw-r--r--view_functions.py2
-rw-r--r--views.py4
7 files changed, 5 insertions, 46 deletions
diff --git a/README.md b/README.md
index e376da9..bd3f1e6 100644
--- a/README.md
+++ b/README.md
@@ -189,12 +189,6 @@ or for files run under 'site'
`home.html`
-You can also make use of the Flask-Caching module to optimize your
-site's perfomance. There are many options available and to be honest, I don't know much about them, but a simple cache of 5 minutes is provided by default. You'll want to read the
- [Flask-Caching
-docs](https://flask-caching.readthedocs.io/en/latest/index.html)
- before experimenting.
-
### Other Tips
There are a few special directories linked that are needed to
diff --git a/requirements.txt b/requirements.txt
index b3c4209..63d0835 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -7,4 +7,3 @@ pip==20.3.4
setuptools==44.1.1
Werkzeug==2.0.1
Flask-Compress==1.10.1
-Flask-Caching==1.10.1
diff --git a/rss_generator.py b/rss_generator.py
index eb4ca82..bde4645 100644
--- a/rss_generator.py
+++ b/rss_generator.py
@@ -1,5 +1,5 @@
import os
-from time import strftime, strptime, ctime
+from time import strftime, strptime
from siteconfig import siteconfig
from view_functions import is_hidden_path, file_last_modified
@@ -9,7 +9,7 @@ class RSS_Item:
RSS_Item - a (very) basic implementation of an object in an RSS
feed using only essential parameters as specified in:
https://www.rssboard.org/rss-specification#hrelementsOfLtitemgt
-
+
Item data is generated from a given file path
"""
PARAGRAPHS = siteconfig.rss_channel_config['DESCRIPTION_LENGTH']
diff --git a/server.py b/server.py
index ab66ccc..f3892c0 100644
--- a/server.py
+++ b/server.py
@@ -4,12 +4,10 @@ server.py - sets up and runs the flask server
from flask import Flask
from siteconfig import siteconfig
from flask_compress import Compress
-from flask_caching import Cache
-from rss_generator import RSS_Item, get_rss_channel
+from rss_generator import get_rss_channel
app = Flask(__name__)
compress = Compress()
-cache = Cache(config=siteconfig.cache_config)
from views import *
@@ -33,6 +31,5 @@ def setup():
# Setup needs to come first to be compatible with wsgi
setup()
compress.init_app(app)
-cache.init_app(app)
if __name__ == "__main__":
app.run()
diff --git a/siteconfig.py b/siteconfig.py
index 2f0f592..4a653d4 100644
--- a/siteconfig.py
+++ b/siteconfig.py
@@ -34,35 +34,6 @@ class siteconfig(config):
# see here https://pypi.org/project/Flask-Compress/
COMPRESS_MIMETYPES = list(config.MIMETYPES.values())
- # Options for Flask Caching
- # https://flask-caching.readthedocs.io/en/latest/#configuring-flask-caching
- cache_config = {
- 'CACHE_TYPE': "SimpleCache",
- 'CACHE_DEFAULT_TIMEOUT': 10,
- # You should only fill ONE of the sections below
- # uswgi
- 'CACHE_UWSGI_NAME': None,
- ##
- # memcache
- 'CACHE_MEMCACHED_SERVERS': None,
- 'CACHE_MEMCACHED_USERNAME': None,
- 'CACHE_MEMCACHED_PASSWORD': None,
- ##
- # redis
- 'CACHE_REDIS_HOST': None,
- 'CACHE_REDIS_PORT': None,
- 'CACHE_REDIS_PASSWORD': None,
- 'CACHE_REDIS_DB': None,
- 'CACHE_REDIS_URL': None,
- 'CACHE_REDIS_SENTINELS': None,
- 'CACHE_REDIS_SENTINEL_MASTER': None,
- 'CACHE_REDIS_CLUSTER': None,
- ##
- # filesystem
- 'CACHE_DIR': None,
- # add more options as needed from the URL above
- }
-
# RSS Settings
rss_channel_config = {
'TITLE': "RSS Feed for example.net",
diff --git a/view_functions.py b/view_functions.py
index 960271f..3de8687 100644
--- a/view_functions.py
+++ b/view_functions.py
@@ -3,7 +3,7 @@ view_functions.py - defines functions called by views to display the correct dat
about files and paths.
"""
import os
-from time import strftime, strptime, ctime
+from time import ctime
from siteconfig import siteconfig
diff --git a/views.py b/views.py
index 7b12e35..d69ac51 100644
--- a/views.py
+++ b/views.py
@@ -6,7 +6,7 @@ import os
from flask import send_from_directory, abort
from flask import render_template, render_template_string, make_response
from siteconfig import siteconfig
-from server import app, cache
+from server import app
from view_functions import *
# bit of a hack.
@@ -20,7 +20,6 @@ CONTENT_BLOCK = (
@app.route("/")
@app.route("/home.html")
@app.route("/index.html")
-@cache.cached()
def home():
"""
home - renders the template `home.html` as the main index file
@@ -37,7 +36,6 @@ def home():
# from: https://pythonise.com/series/learning-flask/sending-files-with-flask
@app.route("/<path:path>")
-@cache.cached()
def render_file(path):
"""
render_file - renders an HTML document for the given `path`.