Simulate streaming API with FastAPI

153 , , 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

132 , 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

297 , 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…