{"id":26795870,"url":"https://github.com/shearichard/fastapi_session","last_synced_at":"2026-05-02T14:31:33.795Z","repository":{"id":285070811,"uuid":"956973044","full_name":"shearichard/fastapi_session","owner":"shearichard","description":"How do session work with FastAPI ?","archived":false,"fork":false,"pushed_at":"2025-03-29T09:14:47.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T10:23:30.247Z","etag":null,"topics":["fastapi","python","sessions","starlette","starlette-middleware"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shearichard.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-29T08:49:43.000Z","updated_at":"2025-03-29T09:14:51.000Z","dependencies_parsed_at":"2025-03-29T10:23:31.880Z","dependency_job_id":"8d286d02-11b1-4bf2-b3e4-fa68135acb00","html_url":"https://github.com/shearichard/fastapi_session","commit_stats":null,"previous_names":["shearichard/fastapi_session"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shearichard%2Ffastapi_session","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shearichard%2Ffastapi_session/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shearichard%2Ffastapi_session/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shearichard%2Ffastapi_session/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shearichard","download_url":"https://codeload.github.com/shearichard/fastapi_session/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246223325,"owners_count":20743168,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fastapi","python","sessions","starlette","starlette-middleware"],"created_at":"2025-03-29T18:16:16.570Z","updated_at":"2026-05-02T14:31:33.757Z","avatar_url":"https://github.com/shearichard.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Using Sessions in FastAPI\nA project to experiment with the use of sessions from within FastAPI by using the Starlette middleware -  https://www.starlette.io/middleware/#sessionmiddleware .\n\nThe aim here is to replicate parts of the functionality of the Django Sessions facility, as it says in the [Django Sessions doco](https://docs.djangoproject.com/en/5.1/topics/http/sessions/) - _\"The session framework lets you store and retrieve arbitrary data on a per-site-visitor basis. It stores data on the server side and abstracts the sending and receiving of cookies.\"_.\n\n## Starting the server\n### VirtualEnv Initialization\nFrom the root of the project execute ...\n\n```\n$ pipenv shell\n```\n\n### Start Server\nFrom the root of the project execute ...\n```\nuvicorn src.main:app --reload\n```\n\n## Environment Variables\nEnvironment variables specific to this project are defined in the .envrc file, this is not committed to the repos however the .envrc_TEMPLATE provides guidance on the contents of .envrc so that it can be recreated when necessary.\n\n## Secret Key\nOne way to generate the secret key needed to use the Session functionality (and which is stored in the uncommitted .direnv) is this \n\n```\npython3 -c 'import os; print(os.urandom(16).hex())'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshearichard%2Ffastapi_session","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshearichard%2Ffastapi_session","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshearichard%2Ffastapi_session/lists"}