A proposal for requests III.
HTTP/1.1
andHTTP/2
Support.async
/await
support for non-thread-blocking HTTP requests.- Fully type annotated.
- 98% test coverage.
A proposal for requests III.
HTTP/1.1
and HTTP/2
Support.async
/await
support for non-thread-blocking HTTP requests.import aiohttp | |
from django.views.generic import TemplateView | |
class FetchView(TemplateView): | |
template_name = 'index.html' | |
async def get(self, request, *args, **kwargs): | |
async with aiohttp.ClientSession() as session: |
def _get_displayed_page_numbers(current, final): | |
""" | |
This utility function determines a list of page numbers to display, based | |
on the same pagination display style that GitHub use in their issue list pages. | |
This gives us a nice contextually relevant set of page numbers to display. | |
For example: | |
current=14, final=16 -> [1, 2, None, 12, 13, 14, 15, 16] | |
current=2, final=16 -> [1, 2, 3, 4, 5, None, 15, 16] |
* CORS | |
* Werkzeug Debugger | |
* Routing | |
* Whitenoise | |
* JWT? | |
* Cache? | |
* ->WSGI / ->ASGI | |
* Pub/Sub | |
* Multipart |
import asyncio | |
import time | |
import threading | |
import queue | |
async def foo(q): | |
i = 0 | |
while True: | |
q.put(i) |
function formToData(form) { | |
const formData = new FormData(form.get()[0]) | |
var params = new Map() | |
var errors = [] | |
var inputElements = {} | |
// Initially iterate through all the inputs | |
form.find(':input').each(function(key, value) { | |
var elem = $(this) | |
var name = elem.attr('name') |
class ProductPriceSerializer(serializers.Serializer): | |
title = serializers.CharField(source='product.title') | |
price = serializers.IntegerField() |
class Duck(object): | |
def walk(self): | |
print('waddle') | |
def talk(self): | |
print('quack') | |
class Donald(object): | |
def walk(self): |