Skip to content

Instantly share code, notes, and snippets.

View tomchristie's full-sized avatar
🌿

Tom Christie tomchristie

🌿
View GitHub Profile

HTTPCore

A proposal for requests III.

Feature support

  • HTTP/1.1 and HTTP/2 Support.
  • async/await support for non-thread-blocking HTTP requests.
  • Fully type annotated.
  • 98% test coverage.
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]

======================== DEP XXX: Simplified routing syntax

  • DEP: XXX
  • Author: Tom Christie
  • Implementation Team: Tom Christie
  • Shepherd: Tim Graham
  • Status: Draft
  • Type: Enhancement
* 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()
@tomchristie
tomchristie / duck.py
Created October 19, 2016 08:09
Walks like a duck...
class Duck(object):
def walk(self):
print('waddle')
def talk(self):
print('quack')
class Donald(object):
def walk(self):
  • Schema & hypermedia support.
  • Better API documentation options.
  • Client libraries for range of languages.
  • Mature authentication defaults.
  • Faster time-to-production.
  • Performance & monitoring.
  • Debugging tools.
  • Realtime API support & documentation.
  • Highlighting & supporting third party packages.
  • Beta release versions & reducing bus factor.