Migrate pip to uv

35 , , Leave a Comment
uv is a super fast dependency resolver. Assume now your have: .venv: the virtual environment directory requirements.txt: the dependency list file It is easy to migrate from pip to uv with following commands. uv venv .venv source .venv/bin/activate uv init uv add -r requirements.txt

Simulate streaming API with FastAPI

230 , , Leave a Comment
The server code import asyncio import uvicorn from fastapi import FastAPI from fastapi.responses import StreamingResponse app = FastAPI() async def fake_text_streaming(): for i in range(1000): yield b"Fake text #" + str(i).encode() + b"\n" await asyncio.sleep(1) @app.post("/") @app…

From PHP to Python In 10 Minutes

201 , Leave a Comment
PHP and Python are both high-level, interpreted programming languages with a variety of applications, but they have some significant differences in terms of syntax, design philosophy, and use cases. Here's a detailed comparison of the two languages: 1. Purpose and Use Cases PHP: Created by Rasmus Lerdorf in 199…

How to use Gmail to send email in Python

366 , Leave a Comment
1 Add "App password" Go to Google account "Security", navigate to "Signing in to Google" and click "App passwords". Then select a type, here we use "Mail" and custom the device name. Type device name as "airflow", or you can choose any other name. Then…