Asynchronous Web Apps in Python
Asynchronous programming has gained popularity in recent years due to its ability to improve the performance of web applications by executing tasks concurrently without blocking the main thread. Python, known for its simplicity and ease of use, also offers support for writing asynchronous web apps.
One of the most popular frameworks for building asynchronous web apps in Python is AIOHTTP. AIOHTTP allows you to handle incoming HTTP requests asynchronously, making it ideal for handling multiple requests simultaneously.
To get started with AIOHTTP, you first need to install it using pip:
pip install aiohttp
Once you have AIOHTTP installed, you can start creating your asynchronous web app by defining routes and handling requests asynchronously. Here’s a simple example of an asynchronous web app using AIOHTTP:
import aiohttp from aiohttp import web async def handle(request): return web.Response(text="Hello, World!") app = web.Application() app.router.add_get('/', handle) if __name__ == '__main__': web.run_app(app)
With AIOHTTP, you can take advantage of Python’s asyncio library to perform various tasks asynchronously, such as making network requests, reading from files, and executing long-running processes without blocking the main thread.
Overall, asynchronous web apps in Python offer significant performance improvements over traditional synchronous web apps, making them a great choice for building high-performance web applications that can handle a large number of concurrent requests efficiently.
no need to pass self as the first argument in get, post, patch…functions ?
Wow! This is one of the best ASGI videos out there. Pure information for fundamentals building. Thank you very much. Keep posting more such videos.
Amazing
Kill -9
Similar to other times when you have shown that Python isn't in complete control of its facilities.
Quality content
No he entendido
I am worried that it won't get many views and that the series will stop, even if it will be really useful for a bunch of people (if not now, in the future, when algorithm might decide so)
What is print(objects…)?
Very enlightening! Thanks!
Instructions unclear. Started raising a whole herd of goats
dude, thanks! I was just tasked to understand our core FastAPI app at my company, this is perfect!
Waw, what a video! Thanks, awesome content!
That's a cool quest to undertake. I'll make sure to follow along, going to be an interesting journey. Thanks!
Asynchronous programming is still so weird to me 😭
T-H-A-T
I-S
G-R-E-A-T
!!!
Hi James, a big thumbs up 👍 for your clear and excellent explanation connecting the ASGI theory/defintion to actual REST API building libraries. Some time ago a colleague asked me to write a simple REST API. I used used FastAPI. That was quite easy to do but then he asked me a feature I did not know how to implement, simply because I did not know about the 'structure' of ASGI that you have explained so well here.
As another viewer wrote, your videos are true gold! Keep 'm coming.
Great content! Thanks for breaking this down
2:32 im very curious now
This series will be one of the best series for developers for years to come. Can't wait for the next video. Absolute banger of a vid!
Awesome content! Been using FastAPI at work and this content is so illustrative of technical details behind the scenes. Mission accomplished, thank you!