forked from auredentan/starlette-session
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b678e2a
commit 4df7947
Showing
14 changed files
with
738 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
# Changelog | ||
# Changelog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
.DEFAULT_GOAL := help | ||
|
||
PY_SRC := starlette_session/ tests/ examples/ | ||
CI ?= false | ||
TESTING ?= false | ||
|
||
.PHONY: help | ||
help: ## Print this help. | ||
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9_-]+:.*?## / {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort | ||
|
||
.PHONY: clean | ||
clean: ## Delete temporary files. | ||
@rm -rf build 2>/dev/null | ||
@rm -rf .coverage* 2>/dev/null | ||
@rm -rf dist 2>/dev/null | ||
@rm -rf .mypy_cache 2>/dev/null | ||
@rm -rf pip-wheel-metadata 2>/dev/null | ||
@rm -rf .pytest_cache 2>/dev/null | ||
@rm -rf starlette_session/*.egg-info 2>/dev/null | ||
@rm -rf starlette_session/__pycache__ 2>/dev/null | ||
@rm -rf site 2>/dev/null | ||
@rm -rf tests/__pycache__ 2>/dev/null | ||
@rm -rf *.egg-info 2>/dev/null | ||
@find . -name "*.rej" -delete 2>/dev/null | ||
|
||
.PHONY: docs | ||
docs: doc-regen ## Build the documentation locally. | ||
@poetry run mkdocs build | ||
|
||
.PHONY: doc-regen | ||
doc-regen: | ||
cp README.md docs/index.md | ||
|
||
.PHONY: docs-serve | ||
docs-serve: doc-regen ## Serve the documentation (localhost:8000). | ||
@poetry run mkdocs serve | ||
|
||
.PHONY: doc-deploy | ||
docs-deploy: doc-regen ## Deploy the documentation on GitHub pages. | ||
@poetry run mkdocs gh-deploy | ||
|
||
.PHONY: changelog | ||
changelog: ## Update the changelog in-place with latest commits. | ||
@poetry run failprint -t "Updating changelog" -- python scripts/update_changelog.py \ | ||
CHANGELOG.md "<!-- insertion marker -->" "^## \[(?P<version>[^\]]+)" | ||
|
||
.PHONY: setup | ||
setup: ## Setup the development environment (install dependencies). | ||
@if ! $(CI); then \ | ||
if ! command -v poetry &>/dev/null; then \ | ||
if ! command -v pipx &>/dev/null; then \ | ||
pip install --user pipx; \ | ||
fi; \ | ||
pipx install poetry; \ | ||
fi; \ | ||
fi; \ | ||
poetry install -v | ||
|
||
.PHONY: format | ||
format: ## Run formatting tools on the code. | ||
@poetry run failprint -t "Formatting code" -- black $(PY_SRC) | ||
@poetry run failprint -t "Ordering imports" -- isort -rc $(PY_SRC) | ||
|
||
|
||
.PHONY: release | ||
release: ## Create a new release (commit, tag, push, build, publish, deploy docs). | ||
ifndef v | ||
$(error Pass the new version with 'make release v=0.0.0') | ||
endif | ||
@poetry run failprint -t "Bumping version" -- poetry version $(v) | ||
@poetry run failprint -t "Staging files" -- git add pyproject.toml CHANGELOG.md | ||
@poetry run failprint -t "Committing changes" -- git commit -m "chore: Prepare release $(v)" | ||
@poetry run failprint -t "Tagging commit" -- git tag v$(v) | ||
@poetry run failprint -t "Building dist/wheel" -- poetry build | ||
-@if ! $(CI) && ! $(TESTING); then \ | ||
poetry run failprint -t "Pushing commits" -- git push; \ | ||
poetry run failprint -t "Pushing tags" -- git push --tags; \ | ||
poetry run failprint -t "Publishing version" -- poetry publish; \ | ||
poetry run failprint -t "Deploying docs" -- poetry run mkdocs gh-deploy; \ | ||
f | ||
|
||
|
||
.PHONY: test | ||
test: ## Run the test suite and report coverage. | ||
@poetry run pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,35 @@ | ||
# Starlette Session | ||
|
||
<p align="center"> | ||
|
||
<a href="https://github.com/auredentan/starlette-session/actions?query=workflow%3ATest" target="_blank"> | ||
<img src="https://github.com/auredentan/starlette-session/workflows/Test/badge.svg?branch=master" alt="Test"> | ||
<img src="https://github.com/auredentan/starlette-session/workflows/Test/badge.svg?branch=master" alt="Test"/> | ||
</a> | ||
|
||
<a href="https://pypi.org/project/starlette-session" target="_blank"> | ||
<img src="https://img.shields.io/pypi/v/starlette-session?color=%2334D058&label=pypi%20package" alt="Package version"> | ||
<img src="https://img.shields.io/pypi/v/starlette-session?color=%2334D058&label=pypi%20package" alt="Package version"/> | ||
</a> | ||
|
||
<a href="https://codecov.io/gh/auredentan/starlette-session"> | ||
<img src="https://codecov.io/gh/auredentan/starlette-session/branch/master/graph/badge.svg" /> | ||
<a href="https://codecov.io/gh/auredentan/starlette-session" target="_blank"> | ||
<img src="https://codecov.io/gh/auredentan/starlette-session/branch/master/graph/badge.svg" alt="Code coverage"/> | ||
</a> | ||
|
||
</p> | ||
|
||
--- | ||
|
||
Starlette session middleware | ||
**Documentation:** [https://auredentan.github.io/starlette-session/](https://auredentan.github.io/starlette-session/) | ||
|
||
--- | ||
|
||
# Starlette Session | ||
|
||
Starlette session is a simple session middleware for [starlette](https://github.com/encode/starlette/). It gives you the possibility of backend session with a predefined backend or a custom one. | ||
|
||
## Requirements | ||
|
||
Python 3.6+ | ||
|
||
## Installation | ||
|
||
```bash | ||
pip install starlette-session | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<p align="center"> | ||
|
||
<a href="https://github.com/auredentan/starlette-session/actions?query=workflow%3ATest" target="_blank"> | ||
<img src="https://github.com/auredentan/starlette-session/workflows/Test/badge.svg?branch=master" alt="Test"/> | ||
</a> | ||
|
||
<a href="https://pypi.org/project/starlette-session" target="_blank"> | ||
<img src="https://img.shields.io/pypi/v/starlette-session?color=%2334D058&label=pypi%20package" alt="Package version"/> | ||
</a> | ||
|
||
<a href="https://codecov.io/gh/auredentan/starlette-session" target="_blank"> | ||
<img src="https://codecov.io/gh/auredentan/starlette-session/branch/master/graph/badge.svg" alt="Code coverage"/> | ||
</a> | ||
|
||
</p> | ||
|
||
--- | ||
|
||
**Documentation:** [https://auredentan.github.io/starlette-session/](https://auredentan.github.io/starlette-session/) | ||
|
||
--- | ||
|
||
# Starlette Session | ||
|
||
Starlette session is a simple session middleware for [starlette](https://github.com/encode/starlette/). It gives you the possibility of backend session with a predefined backend or a custom one. | ||
|
||
## Requirements | ||
|
||
Python 3.6+ | ||
|
||
## Installation | ||
|
||
```bash | ||
pip install starlette-session | ||
``` |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from starlette.applications import Starlette | ||
from starlette.requests import Request | ||
from starlette.responses import JSONResponse | ||
from starlette.routing import Route | ||
|
||
from starlette_session import SessionMiddleware | ||
|
||
|
||
async def setup_session(request: Request) -> JSONResponse: | ||
request.session.update({"data": "session_data"}) | ||
return JSONResponse({"session": request.session}) | ||
|
||
|
||
async def clear_session(request: Request): | ||
request.session.clear() | ||
return JSONResponse({"session": request.session}) | ||
|
||
|
||
async def view_session(request: Request) -> JSONResponse: | ||
return JSONResponse({"session": request.session}) | ||
|
||
|
||
routes = [ | ||
Route("/setup_session", endpoint=setup_session), | ||
Route("/clear_session", endpoint=clear_session), | ||
Route("/view_session", endpoint=view_session), | ||
] | ||
|
||
app = Starlette(debug=True, routes=routes) | ||
app.add_middleware(SessionMiddleware, secret_key="secret", cookie_name="cookie22") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
site_name: Starlette Session | ||
site_description: Session middleware for starlette. | ||
|
||
site_name: Starlette Session | ||
site_description: Session middleware for starlette. | ||
site_url: "https://auredentan.github.io/starlette-session" | ||
repo_url: "https://github.com/auredentan/starlette-session" | ||
repo_name: "auredentan/starlette-session" | ||
|
||
nav: | ||
- Overview: index.md | ||
|
||
theme: | ||
name: material | ||
|
||
markdown_extensions: | ||
- admonition | ||
- codehilite: | ||
guess_lang: false | ||
- pymdownx.superfences | ||
- pymdownx.tasklist | ||
- pymdownx.emoji | ||
- pymdownx.tabbed | ||
- toc: | ||
permalink: "¤" | ||
|
||
plugins: | ||
- search | ||
- mkdocstrings: | ||
handlers: | ||
python: | ||
setup_commands: | ||
- import sys | ||
- sys.path.append("docs") | ||
watch: | ||
- starlette_session |
Oops, something went wrong.