WSGI vs ASGI Protocols

Comprehensive guide comparing WSGI and ASGI protocols in Python web development. Learn key differences, implementation examples, and when to use each protocol for optimal web application performance.

1 min read
def app(environ, start_response):
 start_response('200 OK', [('Content-Type', 'text/plain')])
 return [b'Hello, World!'] 

Réflexions 2024

Un résumé des livres que j'ai lus et des choses que j'ai apprises en 2024.

1 min read
> La simplicité est la sophistication ultime. - Leonardo da Vinci

Concurrency and Multithreading

1 min read
async def fetch(url: str) -> str:
 async with aiohttp.ClientSession() as session:
 async with session.get(url) as response:
 return await response.text()

Terminal Basics

Terminal Basics

1 min read
 mkdir dir_name
 cd dir_name
 touch file_name
 echo 'foo' > file_name
 ls
 cat file_name
 rm file_name
 

Python Great Features

Python Great Features

1 min read
def stateful_function():
 cache = {}
 def wrapper_function(*args, **kwargs):
    key = str(args) + st(kwargs)
    if key not in cache:
       cache[key] = func(*args, **kwargs)
     return cache[key]

 return wrapper_function

@stateful_function
 def fibonacci(n):
    if n < 2:
      return n
    return fibonacci(n-1) + fibonacci(n-2) 

Python Virtual Environments

1 min read
 FROM python:3.7
 WORKDIR ['/app']
 COPY ['requirements.txt', '/app']
 RUN ['pip', 'install', '--no-cache-dir', 'upgrade', '-r', 'requirements.txt']
 COPY ['/app', '/app']
 CMD ['uvicorn', 'app:app', '--host', '0.0.0.0', '--port', '80' 

Python Basics

Python is a great language for beginners and experts alike. Let's explore the basics of Python. From modules, packages, scope, and more. Let's dive in!

1 min read
def outer():
  x = 'local'
  def inner():
     nonlocal x
     x = 'nonlocal'
 inner()

if __name__ == '__main__':
   outer()