Skip to main content

Parse and order a HTTP Accept header.

Project description

https://travis-ci.org/rhyselsmore/accept.png?branch=master https://pypip.in/d/accept/badge.png

A simple library for parsing and ordering a HTTP Accept header.

Includes parameter extraction.

Installation

pip install accept

Or if you must use easy_install:

alias easy_install="pip install $1"
easy_install accept

Usage

>>> import accept
>>> accept.parse("text/*, text/html, text/html;level=1, */*")
[<Media Type: text/html; q=1.0; level=1>, <Media Type: text/html; q=1.0>, <Media Type: text/*; q=1.0>, <Media Type: */*; q=1.0>]
>>> d = accept.parse("application/json; version=1; q=1.0; response=raw")[0]
>>> d.media_type
'application/json'
>>> d.quality
1.0
>>> d.q
1.0
>>> d.params
{'version': '1', 'response': 'raw'}
>>> d['version']
'1'
>>> d['potato']
None

Contribute

  1. Check for open issues or open a fresh issue to start a discussion around a feature idea or a bug. There is a Contributor Friendly tag for issues that should be ideal for people who are not very familiar with the codebase yet.

  2. Fork the repository on Github to start making your changes to the master branch (or branch off of it).

  3. Write a test which shows that the bug was fixed or that the feature works as expected.

  4. Send a pull request and bug the maintainer until it gets merged and published.

History

0.1.0 (2015-01-05)

  • Initial Release!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

accept-0.1.0.tar.gz (4.3 kB view details)

Uploaded Source

File details

Details for the file accept-0.1.0.tar.gz.

File metadata

  • Download URL: accept-0.1.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for accept-0.1.0.tar.gz
Algorithm Hash digest
SHA256 760241df3a6be5a5c4f00682a381280a8c3c7e0286fd55612f68d0f9e9dcfed4
MD5 924283e7d43b81006eeccfd69d2873f6
BLAKE2b-256 21c4979ec79b3d6b9a882a75930f7342d8144c2bb4bff340777c3ea6d222678a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page