FastApi Stuck at Loading, when passing base64 image
from typing import Annotated from fastapi import FastAPI, Path, Form from pydantic import BaseModel import base64 class file(BaseModel): name: str data: str app = FastAPI() @app.post(“/upload”) def upload(filename: str = Form(…), filedata: str = Form(…)): image_as_bytes = str.encode(filedata) # convert string to bytes img_recovered = base64.b64decode(image_as_bytes) # decode base64string try: with open(“uploaded_” + filename, “wb”) […]
SQLAlchemy repositories: a minimal example
I am building an API at work. For that, I use Python library FastAPI as web framework and SQLAlchemy for database management. Since I know, model repository is the neatest way to handle database interactions, I define a SQLAlchemy model called User
and try to advance based on this approach for others in case it works succesfully.