Giter VIP home page Giter VIP logo

status's Introduction

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.

status's People

Contributors

avinassh avatar vaibhavmule avatar davidbgk avatar kracekumar avatar ryansb avatar sriram-mv avatar harryhaos avatar pdex avatar

Stargazers

GaboBardales avatar Alan Szmyt avatar  avatar William Rodrigues avatar 凌诗韵 avatar Jarooony avatar Beatriz Uezu avatar Bob.an avatar  avatar  avatar 林煒清(Lin Wei-Ching) avatar Eyal Trabelsi avatar Felipe Frizzo avatar Osvaldo Santana Neto avatar Rafael Francischini avatar  avatar u avatar Mark avatar Christian Killer avatar Etem Hyusnev avatar  avatar 林果皞 avatar Duane avatar Charlie Denton avatar BC avatar Indrajith Bandara avatar Anderson Araujo avatar Kirill Vostretsov avatar nicolastrres avatar  avatar João avatar George Kussumoto avatar Bruno Soares avatar Theofanis Despoudis avatar GAURAV avatar Minsung Kim avatar Brian Pandola avatar Hyungjin Shin avatar Виктор Усачёв avatar Elliot Gerchak avatar jcrashkit avatar Emiel van de Laar avatar Syed Hasan raza avatar Robin Curbelo avatar  avatar Danqing Shi avatar Hakam avatar Igor Khvan avatar 陈薪 avatar ya avatar Mukesh Munisubbanna avatar Marcus R. Brown avatar Trevor Olson avatar  avatar Carlos avatar Andrii Trybynenko avatar Andrew Shaffer avatar J Phani Mahesh avatar Ivan Krivosheev avatar  avatar Yaser Alraddadi avatar Taranjeet Singh avatar Edgar Gabaldi avatar Thomas O'Donnell avatar Minho Ryang avatar Nathan Jordan avatar sl kim avatar Alexander Myasoedov avatar Arthur Alvim avatar Gabriel Falcão avatar George avatar Francois Lebel avatar Justin Mayer avatar Zsombor Szántó avatar Tanky Woo avatar Igor P. Leroy avatar Richard Baumann avatar David Warden avatar Mike TUMS avatar Stéphane Reynders avatar Wiliam Souza avatar Carl Huang avatar Jonathan Barratt avatar Avin Varghese avatar Pedro Ramon avatar Angus H. avatar yoCruzer avatar  avatar netxfly avatar Oscar A. Mata T. avatar Alessio avatar yi avatar  avatar Amjad Ali avatar Yoichi Fujimoto avatar sungjin.kang avatar BlancosWay avatar Mevin avatar Toly avatar Utkarsh Bhatt avatar

Watchers

 avatar (◕ᴥ◕) avatar Joeny Bui avatar Robin Curbelo avatar  avatar  avatar

status's Issues

Code checker

I would add a function that checks that if the code is out of the valid range, then False is returned:
def is_bad_code(code): return 100 < code or code >= 526

Licensing is invalid

You cannot copy a file wholesale from another project with copyright and licensing written one way and then add your own license claiming copyright for something you did not implement. The License must reflect the actual copyright (Tom Christie)

More codes

Hello!
it seems to me that some useful status codes are missing:
499 and codes from 520 to 526

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.