Archives mensuelles : mars 2023

Flask Rest json with Marshmallow

Models Person from dataclasses import dataclass from typing import List   from flask_example import db from models.Address import Address     @dataclass class Person(db.Model): id: int = db.Column(db.Integer, primary_key=True) firstname: str = db.Column(db.String) lastname = db.Column(db.String) addresses = db.relationship(’Address’, back_populates=’person’, … Continuer la lecture

Publié dans Non classé | Laisser un commentaire

Flask-SQLAlchemy

Set up flask with SQLAlchemy Integrates SQLAlchemy with Flask from flask import Flask from flask_sqlalchemy import SQLAlchemy   app: Flask = Flask(__name__) db: SQLAlchemy = SQLAlchemy() # The import of MySQLAlchemyConfiguration must be after the initialization of db (SQLAlchemy instance) … Continuer la lecture

Publié dans Non classé | Laisser un commentaire

Flask: common problems

Common SQLAlchemy/marshmallow problems Problem: Object initialization order issue. In python and still more to in flask, the order of import and instantiation of python files and classes matters. To make it consistent, we need to be very careful. We can … Continuer la lecture

Publié dans Non classé | Laisser un commentaire

Flask general

Start the application Start the application which the python file is flask_example.py and run it on the port 5001 with the debug options: flask –app flask_example run –port 5001 –debug Routes List all routes mapping: Suppose your flask application file … Continuer la lecture

Publié dans Non classé | Laisser un commentaire

Python install modules

Problem: During a module install, error such as: ERROR: Could not build wheels for pyaudio which use PEP 517 and cannot be installed directly Exception information: Traceback (most recent call last): File "/home/david/whisper_real_time/venv/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 186, in _main status = self.run(options, … Continuer la lecture

Publié dans Non classé | Laisser un commentaire

github action workflow examples

Java and docker compose example with a reusable workflow Reusable test execution workflow Key points: – reusable workflow – specify expression – set specific permissions for the job – specify input parameter for actions – Upload an artifact – specify … Continuer la lecture

Publié dans Non classé | Laisser un commentaire

github actions general

General Workflows – it runs one or more jobs. – it is defined by a YAML file located in to your github repository and will run when triggered by an event in your repository, or they can be triggered manually, … Continuer la lecture

Publié dans Non classé | Laisser un commentaire