mastodon.xyz is one of the many independent Mastodon servers you can use to participate in the fediverse.
A Mastodon instance, open to everyone, but mainly English and French speaking.

Administered by:

Server stats:

812
active users

#fastapi

6 posts2 participants0 posts today

Always a good day when you get to shut down an old backend service. It was finally time to move my old Flask based server to the heavenly hunting grounds. It's been fully superseded since quite a while by a FastAPI based one. No clients really used the old one anymore so shutting it down was a pretty easy decision to make.

Continued thread

Un altre descobriment en aquest camí ha estat #Pydantic. Com podia viure programàticament parlant sense Pydantic?
Pydantic és una biblioteca de Python que serveix per validar i gestionar dades amb tipus. Et permet definir models (com classes) on s’especifica el tipus de cada camp, i automàticament valida i converteix les dades rebudes. Integrat a la perfecció amb fastAPI.

Continued thread

Totes les aplicacions client per Android funcionen amb #appy i el mateix passa amb les de iOS. Aquesta és la clau, volia aprofitar totes les apps existents per tant l'API havia de ser una copia de la de Mastodon però feta amb fastAPI, que ha resultat una tria excel·lent. fastAPI és brutal, fa tot i més i molt bé. I, a més, et genera automàticament la documentació sense ni preocupar-te per ella. Insisteixo, brutal.

Continued thread

L'estructura tècnica d'#appy funciona gràcies a Python, fastAPI, #Postgresql (base de dades) i #Redis (memòria cau).
Tot de manera asincrona per evitar punts de bloqueig, passen moltes coses en parall·lel, simultàniament, bàsic per a tenir fluïdesa tant en les interaccions amb altres servidors com amb les aplicacions client.
appy funciona bé fins i tot en una #Raspberry 4B, per tant també és una opció vàlida per a tenir el perfil fediversal auto gestionat i a casa.

Continued thread

Quan vaig posar en marxa mastodont.cat no en sabia res de Python i ActivityPub no existia (Mastodon funcionava a les hores amb el protocol Ostatus de GNU Social).
Qui podria pensar que acabaria programant el meu propi servidor? sí, estic content d'haver-ho aconseguit i de compartir el resultat amb la comunitat de programari lliure a codeberg.org/spla/appy
Queda feina encara però sí, ja ho considero un èxit 😃

Summary card of repository spla/appy
Codeberg.orgappya headless ActivityPub server written with Python and fastAPI.

Queden algorismes per polir, afegir funcionalitats com ara bloquejar o silenciar usuaris i servidors i depurar incidències però ja considero que #appy és un èxit.
Des de juny de l'any passat he estat (i estic) molt centrat en desenvolupar el meu propi servidor ActivityPub des de zero, sense copiar res de ningú, per pur plaer personal de superar reptes. He après molt pel camí, no és gens fàcil però he gaudit molt de cada fita.
Va ser tot un encert triar #Python i #fastAPI, van sobrats.

Continued thread

I thought I was joking when I started writing that. But.. trivial extra overhead, fortune's ready to apt-get install. My little web service front-end is #nginx + #FastAPI in #Python.

It'd be nothing to make a reject filter for bad URIs that aren't valid for this system and return subprocess.getoutput() and write what's returned back to the curious caller.

Some of the code calling is surely logging weird replies it gets. That'd be fun.

Not high priority fun, but on the list.

I am probably holding them wrong!

This time I tried writing a web app not in #php but #fastapi + #sqlmodel (python) and #vue3 ( javascript). It kind of works well but refactoring is a nightmare.

In the beginning, it felt like I was having the best of both worlds -- Python and Vue3. Dev speed was good. Now maintaining and refactoring make me feel like I am having the worst of both worlds.

As a single dev, I should have stayed with #php!

So I've never done any web stuff and don't understand it - and also I wanted to see if my API was understandable (at least by a chatbot if not a human).

So *I* didn't write the Python code so far... (ok that's kinda a lie.. I had to show GPT the equivalent bits from my notebook to integrate bit by bit).

I basically did two days of Socratic direction of GPT which.. worked. It chose #FastAPI and turned my long winded explanations into one-liners using other libraries I didn't know about.

Anyone knows of a #Python library that can make a #fastapi route method act as an #mcp resource or tool, while also keeping its default functionality (JSON API, maybe SSR) with full dependency resolution and Pydantic support (obviously two separate routes/paths are necessary in this case)?

The official mcp Python SDK doesn't seem to match these requirements unfortunately, even though it's based on Starlette..

Thinking about implementing one, but it would be really nice if it already existed.