This article lives in:

Intro

FastAPI version 0.62.0 comes with global dependencies that you can apply to a whole application.

Include a router

Imagine you had a file users.py with:

from fastapi import APIRouterrouter = APIRouter()
@router.get("/users/")
def read_users():
return ["rick", "morty"]

And now let’s say you want to include it in the main.py


This article lives in:

Intro

Modern versions of Python (and other languages) have support for “asynchronous code” using something called “coroutines”, with async and await syntax.


This article lives in:

The first FastAPI workshop at PyCon Belarus

Last weekend I had the chance to go to PyCon Belarus, I had a great time and met a lot of great people.

And a workshop with about 60 people:

Creating the workshop

When creating the workshop I got a bit excited and created too much content for the time I had available.


Here’s a tip to help you get started contributing to open source (if you haven’t started yet).

TL;DR

(too long, didn’t read)

Find a problem

First, find a problem that you want to solve, something that you care about.

Find a project

Then find an open source project that would help to solve that problem. …


FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.6+ based on standard Python type hints.

This article lives in:

Intro

I have been avoiding the creation of a new framework for several years. First I tried to solve all the features covered by FastAPI using many different frameworks, plug-ins, and tools.


This article lives in:

Intro

Let’s say you already set up a Docker Swarm mode cluster as described in DockerSwarm.rocks, with a Traefik distributed HTTPS proxy.

  • Monitor CPU, disk, memory usage, etc.
  • Monitor it all per node, per service, per container, etc.
  • Have a nice, interactive, real-time dashboard with all the data nicely plotted.
  • Trigger alerts (for example, in Slack, Rocket.chat, etc) when your services/nodes pass certain thresholds.
  • And more…

Swarmprom is actually just a set of tools pre-configured in a smart way for a Docker Swarm cluster. …


This article lives in:

Intro

So, you have a Docker Swarm mode cluster set up as described in DockerSwarm.rocks.

  • Handle connections.
  • Expose specific services and applications based on their domain names.
  • Handle multiple domains (if you need to). Similar to “virtual hosts”.
  • Handle HTTPS.
  • Acquire (generate) HTTPS certificates automatically (including renewals) with Let’s Encrypt.
  • Add HTTP Basic Auth for any service that you need to protect and doesn’t have its own security, etc.
  • Get all its configurations automatically from Docker labels set in your stacks (you don’t need to update configuration files). …


This article lives in:

Update

I created DockerSwarm.rocks to put these and related ideas together.

Note

If you want to have a distributed Traefik HTTPS proxy/load-balancer, you should check instead the guide for the distributed version on DockerSwarm.rocks: Traefik Proxy with HTTPS. It can also run on a single node.


Note: There’s an equivalent article for Angular in Medium and GitHub.


This article lives in:

Intro

At Senseta we have many complex requirements for our systems, as part of that, in many cases, we need to create equally complex full-stack web applications.

First steps

At some point, as part of my “free time experiments”, I created the first version of an open source Docker image to deploy Flask applications.

About

Sebastián Ramírez

Creator of FastAPI and Typer. Dev at Exposion AI. APIs, Deep Learning/Machine Learning, full-stack distributed systems, SQL/NoSQL, Python, Docker, JS, TS, etc.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store