Skip to content

Commit

Permalink
Minor updates to docs and example
Browse files Browse the repository at this point in the history
  • Loading branch information
Lxstr committed Feb 19, 2024
1 parent 166372d commit ec15a65
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 15 deletions.
2 changes: 2 additions & 0 deletions docs/_static/styles.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import url('https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:ital,wght@0,400;0,700;1,400;1,700&family=Source+Code+Pro:ital,wght@0,400;0,700;1,400;1,700&display=swap');

.padded {
padding: 40px;
}
35 changes: 24 additions & 11 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
project = "Flask-Session"
author = "Pallets Community Ecosystem"
copyright = f"2014, {author}"
release = importlib.metadata.version("Flask-Session")
version = release = importlib.metadata.version("Flask-Session")

# General --------------------------------------------------------------

extensions = ["sphinx.ext.autodoc", "sphinx.ext.intersphinx", "sphinx_favicon"]

Expand All @@ -14,14 +16,9 @@
"flask-sqlalchemy": ("http://flask-sqlalchemy.palletsprojects.com/", None),
}

html_theme = "furo"
html_static_path = ["_static"]
html_css_files = [
"styles.css",
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/fontawesome.min.css",
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/solid.min.css",
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/brands.min.css",
]

# HTML -----------------------------------------------------------------

favicons = [
{"rel": "icon", "href": "icon.svg", "type": "image/svg+xml"},
{"rel": "icon", "sizes": "16x16", "href": "favicon-16x16.png", "type": "image/png"},
Expand Down Expand Up @@ -50,16 +47,31 @@
"href": "safari-pinned-tab.svg",
},
]


html_copy_source = False
html_css_files = [
"styles.css",
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/fontawesome.min.css",
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/solid.min.css",
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/brands.min.css",
]
html_domain_indices = False
html_static_path = ["_static"]
html_theme = "furo"
html_theme_options = {
"source_repository": "https://github.com/pallets-eco/flask-session/",
"source_branch": "main",
"source_directory": "docs/",
"light_logo": "logo/logo-light.png",
"dark_logo": "logo/logo-dark.png",
"light_css_variables": {
"font-stack": "'Atkinson Hyperlegible', sans-serif",
"font-stack--monospace": "'Source Code Pro', monospace",
"color-brand-primary": "#39A9BE",
"color-brand-content": "#39A9BE",
},
"dark_css_variables": {
"font-stack": "'Atkinson Hyperlegible', sans-serif",
"font-stack--monospace": "'Source Code Pro', monospace",
"color-brand-primary": "#39A9BE",
"color-brand-content": "#39A9BE",
},
Expand All @@ -86,3 +98,4 @@
},
],
}
html_use_index = False
2 changes: 2 additions & 0 deletions docs/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Configuration

.. include:: config_security.rst

.. include:: config_exceptions.rst

.. include:: config_flask.rst

.. include:: config_flask_session.rst
Expand Down
19 changes: 15 additions & 4 deletions examples/hello.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from flask import Flask, session
from flask_session import Session
from redis.exceptions import RedisError

app = Flask(__name__)
app.config.from_object(__name__)
app.config.update(
{
"SESSION_TYPE": "redis",
"FLASK_ENV": "production",
}
)
Session(app)
Expand All @@ -19,13 +21,22 @@ def set():

@app.route("/get/")
def get():
import time

start_time = time.time()
result = session.get("key", "not set")
print("get", (time.time() - start_time) * 1000)
return result


@app.route("/delete/")
def delete():
# del session["key"]
raise RedisError("test")
return "deleted"


@app.errorhandler(RedisError)
def handle_redis_error(error):
app.logger.error(f"Redis error encountered: {error}")
return "A problem occurred with our Redis service. Please try again later.", 500


if __name__ == "__main__":
app.run(debug=True)

0 comments on commit ec15a65

Please sign in to comment.