{"id":13424722,"url":"https://github.com/AGeekInside/fastapi-jinja","last_synced_at":"2025-03-15T18:35:50.856Z","repository":{"id":51311850,"uuid":"307512059","full_name":"AGeekInside/fastapi-jinja","owner":"AGeekInside","description":"Adds integration of the Jinja template language to FastAPI.","archived":false,"fork":true,"pushed_at":"2024-11-16T02:53:24.000Z","size":29,"stargazers_count":69,"open_issues_count":1,"forks_count":11,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-16T03:26:12.489Z","etag":null,"topics":["hacktoberfest","hacktoberfest2020"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"mikeckennedy/fastapi-chameleon","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AGeekInside.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-26T21:44:13.000Z","updated_at":"2024-11-16T02:53:28.000Z","dependencies_parsed_at":"2023-01-18T16:21:05.859Z","dependency_job_id":null,"html_url":"https://github.com/AGeekInside/fastapi-jinja","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AGeekInside%2Ffastapi-jinja","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AGeekInside%2Ffastapi-jinja/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AGeekInside%2Ffastapi-jinja/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AGeekInside%2Ffastapi-jinja/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AGeekInside","download_url":"https://codeload.github.com/AGeekInside/fastapi-jinja/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243775916,"owners_count":20346286,"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":["hacktoberfest","hacktoberfest2020"],"created_at":"2024-07-31T00:00:58.341Z","updated_at":"2025-03-15T18:35:45.840Z","avatar_url":"https://github.com/AGeekInside.png","language":"Python","readme":"# fastapi-jinja\n\nAdds integration of the Jinja template language to FastAPI. This is inspired and based off fastapi-chamelon by Mike Kennedy. Check that out, if you are using chamelon.\n\n## Installation\n\nFor the moment, this is not yet on pypi and is fairly unstable, but if you wish to used it directly from here, just do the following:\n\n```bash\npip install git+https://github.com/ageekinside/fastapi-jinja\n```\n\nYou may want to fork this repo and then use your URL until this is more final.\n\n## Usage\n\nThis is easy to use. Just create a folder within your web app to hold the templates such as:\n\n```\n├── main.py\n├── views.py\n│\n├── templates\n│   ├── home\n│   │   └── index.j2\n│   └── shared\n│       └── layout.j2\n\n```\n\nIn the app startup, tell the library about the folder you wish to use:\n\n```python\nimport os\nimport fastapi_jinja\n\ndev_mode = True\n\nfolder = os.path.dirname(__file__)\ntemplate_folder = os.path.join(folder, 'templates')\ntemplate_folder = os.path.abspath(template_folder)\n\nfastapi_jinja.global_init(template_folder, auto_reload=dev_mode)\n```\n\nThen just decorate the FastAPI view methods (works on sync and async methods):\n\n```python\n@router.post('/')\n@fastapi_jinja.template('home/index.j2')\nasync def home_post(request: Request):\n    form = await request.form()\n    vm = PersonViewModel(**form) \n\n    return vm.dict() # {'first':'John', 'last':'Doe', ...}\n\n```\n\nThe view method should return a `dict` to be passed as variables/values to the template. \n\nIf a `fastapi.Response` is returned, the template is skipped and the response along with status_code and\nother values is directly passed through. This is common for redirects and error responses not meant\nfor this page template.\n","funding_links":[],"categories":["Third-Party Extensions"],"sub_categories":["Utils"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAGeekInside%2Ffastapi-jinja","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAGeekInside%2Ffastapi-jinja","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAGeekInside%2Ffastapi-jinja/lists"}