• Stars
    star
    276
  • Rank 149,319 (Top 3 %)
  • Language
    Python
  • License
    Other
  • Created about 9 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

HTTP Status for Humans

status - HTTP Status for Humans

version supported license

status is a very simple python library which provides human understandable HTTP status codes and improves readability of your code. You don't have to use those ugly HTTP status numbers, but use easily understandable status names.

Don't:

class PythonPeople(RequestHandler):
    def post(self):
        # do stuff
        return ('That worked!', 201)

But, do this:

class PythonPeople(RequestHandler):
    def post(self):
        # do stuff
        return ('That worked!', status.HTTP_201_CREATED)

See, that looks so much better. You can use this library wherever you want, from custom python scripts to Django, Flask etc apps. For example, if you were playing with Requests:

>>> response = requests.delete('http://some-url')
>>> response.status_code == status.HTTP_204_NO_CONTENT

Installation

pip install python-status

Usage

status comes with HTTP response status codes and also some helpful methods to check the response status. Under the hood, status codes are merely an integer variable with meaningful variable names. Check status.py file.

>>> import status
>>> status.HTTP_200_OK == 200
True

For list of available status codes check status.py file.

status also comes with some helpful methods to check the status of a response. They are status.is_informational, status.is_success, status.is_redirect, status.is_client_error and status.is_server_error.

>>> import status
>>> response = requests.delete('http://some-url')
>>> if status.is_success(code=response.status_code):
        print('yay!')
>>> 
yay!

Why?

For every project I was creating a status.py file in the root directory. So I thought it's better to release this as a package on PyPi and use it.

Alternatives

Starting with Python 3.5, the standard library includes HTTP Status enum.

License

Please check LICENSE for more details.

Credits

status is a fork of Django Rest Framework(DRF) and is independently maintained. The fork is entirely stripped of all DRF features and is not a submodule of DRF. And it doesn't come with any DRF functionalities.

More Repositories

1

rockstar

Makes you a Rockstar C++ Programmer in 2 minutes
Python
4,147
star
2

py-caskdb

(educational) build your own disk based KV store
Python
968
star
3

grpc-errors

A handy guide to gRPC errors
C#
549
star
4

fast-sqlite3-inserts

Some bunch of test scripts to generate a SQLite DB with 1B rows in fastest possible way
Rust
337
star
5

gg-flip

Highly performant Javascript library to flip the signs
HTML
174
star
6

pytorch-flask-api

Python
166
star
7

pytorch-flask-api-heroku

HTML
160
star
8

haxor

Unofficial Python wrapper for official Hacker News API
Python
153
star
9

go-caskdb

(educational) build your own disk based KV store in Go
Go
134
star
10

slackipy

Automate user invites to your Slack channel!
Python
87
star
11

della

Della is a Django app for managing Secret Santa/Gift Exchange.
Python
48
star
12

Reddit-GoodReads-Bot

Python
32
star
13

little-finger

Clojure
31
star
14

cowin-assist

Telegram Bot to check covid vaccine slot availability on CoWin site
Python
30
star
15

prawoauth2

Helper library to make your life easier using OAuth2 for PRAW
Python
29
star
16

kylo

The FAQ Bot
Python
16
star
17

history-bleed

Check your browser history against Cloud Bleed
JavaScript
13
star
18

score-notify

Displays cricket score as notification. OS X Only.
Python
11
star
19

dev-startups-india

list of Indian startups working on building developer tools
9
star
20

fluvio-go

Rust
8
star
21

saveourcinema

code which powers http://saveourcinema.in
HTML
8
star
22

ares

Slack Moderator
Go
8
star
23

Hocus-Pocus

Simple OS X app which shows hidden files. Written in Swift.
Swift
8
star
24

breast-cancer-prediction

Jupyter Notebook
7
star
25

openshift-tornado-starter

Simple repo to get started on Openshift with Python Tornado
6
star
26

cemetery.io

HTML
5
star
27

sign-flip

JavaScript
5
star
28

isso-openshift

This repo helps you install Isso on Openshift with a single click
Python
5
star
29

brave-browser-hardening

mirror of https://gitlab.com/CHEF-KOCH/brave-browser-hardening
5
star
30

Laozi

Laozi is a Goodreads bot for Telegram
Python
5
star
31

heroku-tornado-starter

Simple repo to get started on Heroku to serve static files using Python Tornado
Python
5
star
32

nightreads

Python
5
star
33

slackipycore

Invite Users to Slack using Python
Python
4
star
34

talkwithme

simple chatroom built using Tornado
Python
4
star
35

unnamed-wip-document-db

a document database (like mongo) written in Python. Uses CaskDB as storage backend.
4
star
36

learning-scraping

A project written in Django, which aims to teach Web Scraping for beginners.
Python
3
star
37

polistats

Google Search Trends of Indian Politics
Python
3
star
38

kekday

Find a Redditor's Cake Day!
HTML
3
star
39

good-human

Python
2
star
40

gh-vue

A simple Vue JS project to display my latest commits from Github
JavaScript
2
star
41

learning-tornado

Python
2
star
42

btree

An in-memory B Tree implementation in Go
Go
2
star
43

tildes-plus

JavaScript
2
star
44

mca_scraper

Python
2
star
45

gofish

Go
2
star
46

little-finger-android

Java
2
star
47

hugo-skyfall

Hugo theme - skyfall
CSS
2
star
48

mvcc-go

Go
2
star
49

reddit-india-books

What does Reddit India likes to read?
Python
2
star
50

mkstemp

A Hacker News Clone
Python
2
star
51

skyfall

Clean Pelican theme for http://avi.im/blag
HTML
2
star
52

offenders

List of Telecos and Companies which break Net Neutrality
2
star
53

Bitbucket-import

Python
1
star
54

monkey

An interpreter for the Monkey Programming Language in Golang
Go
1
star
55

wutong

A naughty Telegram bot
Python
1
star
56

tornado-benchmarks

pointless tornado benchmarks
Python
1
star
57

FoodPin

Swift
1
star
58

rtiman

Kickstarter for RTIs
Python
1
star
59

avinassh.github.io

HTML
1
star
60

bast

Delete your Reddit comment history safely
Go
1
star
61

blag

hosts my blog
CSS
1
star
62

goodreads-export

CSS
1
star
63

little-finger-ios

Swift
1
star
64

inks

Go
1
star
65

Calculator-Swift

Simple Calculator app written using Swift
Swift
1
star
66

honk

Go
1
star
67

ratelimit

Go
1
star
68

heroku-static

Ruby
1
star
69

build-your-regex

Go port of Rob Pike's Regex Engine (from C)
Go
1
star
70

hugo-publish

My Github Actions setup for publishing a Hugo blog
1
star