API — Jinja Documentation (3.1.x) jinja.palletsprojects.com I’ve definitely been missing out on setting up a proper jinja loader on a few projects, I need to lean on this a bit more. The path can be relative or absolute. Relative paths are relative to the current working directory.
Posts tagged: dev
All posts with the tag "dev"
321 posts
latest post 2026-10-16
Publishing rhythm
Nice intro into tailwind, I definitely started grasping some of the concepts after watching Brad.
Gzip/Brotli Compression Test | GiftOfSpeed Check if Gzip or Brotli compression is working on your website. giftofspeed.com A nice tool to check compression on a public url.
Reasons to avoid Javascript CDNs Wesley Aptekar-Cassels · blog.wesleyac.com And this is why we don’t run cdn in prod, respect your users who can’t control where the assets are stored. There are so many fast static hosting providers out there, if you are worried about performance reasons use one of those to self host.
External Link stackoverflow.com In flask apps I often get a 404 for routes with a trailing slash. This Stack Overflow post shows how to configure flask to allow trailing slashes on some or all routes.
External Link htmx.org json-enc extension converts url encoded form values into json encoded data, this is very useful for fastapi to have the same interface for htmx and curl type of interfaces.
Header Parameters - FastAPI FastAPI framework, high performance, easy to learn, fast to code, ready for production fastapi.tiangolo.com Getting request headers in fastapi has a pretty nice stetup, it allows you to get headers values as function arguments, I was able to use headers to detect if a request was made from htmx or not. If the request was made from htmx, then we want a html format, otherwise I’m probably hitting the api programatically from something like or
Great short explaination of session vs token authentication.
Form Data - FastAPI FastAPI framework, high performance, easy to learn, fast to code, ready for production fastapi.tiangolo.com Getting form data inside of fastapi was not intuitive to me at first. Everything I had used in fastapi leaned on pydantic models. Form data comes in differently and needs collected differently.
Template Designer Documentation — Jinja Documentation (3.1.x) jinja.palletsprojects.com A feature of jinja that I just discovered is including sub templates. Here is an example from the docs. And inside of my thoughts project I used it to render posts. note that post_item. html automatically inherits the post variable.
Templates - FastAPI FastAPI framework, high performance, easy to learn, fast to code, ready for production fastapi.tiangolo.com A guide to add Jinja2Templates to fastapi.
</> htmx ~ Documentation htmx gives you access to AJAX, CSS Transitions, WebSockets and Server Sent Events directly in HTML, using attributes, so you can build modern user interfaces with the simplicity and power of hypert... htmx.org A complete reference of all of the htmx swapping methods.
External Link stackoverflow.com I am trying to use htmx on a new fastapi site for my thoughts, and have been hitting this error. What is happening I have an htmx component that gets the current users name, but if they are not logged in the backend redirects to a login form. But for some reason when the front end gets this redirect, it tries to do it through http, and flags it as insecure. The solution To solve this issue, the post directs to set the to ‘*’
External Link htmx.org Using templates with htmx requires the client-side-templates extension, and the template engine to be loaded in a tag. example htmx using templates.
Static Files - FastAPI FastAPI framework, high performance, easy to learn, fast to code, ready for production fastapi.tiangolo.com Mounting static files in fastapi.
#javascript" playlabel="Play: HTMX looks pretty neat #coding #javascript "> Love the poling example with hx-trigger=‘every 1s’.
External Link github.com Here is a snippet provided by @tiangolo to store the users jwt inside of a session cookie in fatapi. This was written in feb 12, 2020 and admits that this is not a well documented part of fastapi. It’s already in place. More or less like the rest of the security tools. And it’s compatible with the rest of the parts, integrated with OpenAPI (as possible), but probably most importantly, with dependencies. It’s just not properly documented yet. 😞 But still, it works 🚀 e.g.
pytest-subtests unittest subTest() support and subtests fixture PyPI · pypi.org pytest-subtests is a package to register multiple subtests within a similar test function.
A nice codepen reference for dark forms. I am using it for my thoughts chrome extension.
Filter Data - WHERE - SQLModel SQLModel, SQL databases in Python, designed for simplicity, compatibility, and robustness. sqlmodel.tiangolo.com When fetching pydantic models from the database with sqlmodel, and you cannot select your item by id, you probably need to use a where clause. This is the sqlmodel way of doing it. Here is a snippet of how I am using sqlmodel select and where to find a post by link in my thoughts database.
Calendar data could not load. Try again.