├── .gitignore ├── LICENSE ├── README.md ├── feedback.py ├── http_status_code.py ├── icon.png └── status_code.csv /.gitignore: -------------------------------------------------------------------------------- 1 | *.py[cod] 2 | 3 | # C extensions 4 | *.so 5 | 6 | # Packages 7 | *.egg 8 | *.egg-info 9 | dist 10 | build 11 | eggs 12 | parts 13 | bin 14 | var 15 | sdist 16 | develop-eggs 17 | .installed.cfg 18 | lib 19 | lib64 20 | 21 | # Installer logs 22 | pip-log.txt 23 | 24 | # Unit test / coverage reports 25 | .coverage 26 | .tox 27 | nosetests.xml 28 | 29 | # Translations 30 | *.mo 31 | 32 | # Mr Developer 33 | .mr.developer.cfg 34 | .project 35 | .pydevproject 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ilstar/http_status_code/916411486818dce72a3b758793f383e0a6fc6998/LICENSE -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | HTTP Status Code 2 | ================ 3 | 4 | ![screenshot 2014-07-23 11 56 04](https://cloud.githubusercontent.com/assets/128977/3679639/b41e2988-12a6-11e4-94ff-51cb27dc09fc.png) 5 | ![screenshot 2014-07-23 11 55 54](https://cloud.githubusercontent.com/assets/128977/3679640/b67f6084-12a6-11e4-9edd-07afd141f340.png) 6 | 7 | 8 | Dowload from [release page](https://github.com/ilstar/http_status_code/releases) 9 | 10 | icon from https://www.iconfinder.com/iconsets/Milkanodised-png#readme 11 | -------------------------------------------------------------------------------- /feedback.py: -------------------------------------------------------------------------------- 1 | #author: Peter Okma 2 | import xml.etree.ElementTree as et 3 | 4 | 5 | class Feedback(): 6 | """Feeback used by Alfred Script Filter 7 | 8 | Usage: 9 | fb = Feedback() 10 | fb.add_item('Hello', 'World') 11 | fb.add_item('Foo', 'Bar') 12 | print(fb) 13 | 14 | """ 15 | 16 | def __init__(self): 17 | self.feedback = et.Element('items') 18 | 19 | def __repr__(self): 20 | """XML representation used by Alfred 21 | 22 | Returns: 23 | XML string 24 | """ 25 | return et.tostring(self.feedback).decode('utf-8') 26 | 27 | def add_item(self, title, subtitle="", arg="", valid="yes", autocomplete="", icon="icon.png"): 28 | """ 29 | Add item to alfred Feedback 30 | 31 | Args: 32 | title(str): the title displayed by Alfred 33 | Keyword Args: 34 | subtitle(str): the subtitle displayed by Alfred 35 | arg(str): the value returned by alfred when item is selected 36 | valid(str): whether or not the entry can be selected in Alfred to trigger an action 37 | autcomplete(str): the text to be inserted if an invalid item is selected. This is only used if 'valid' is 'no' 38 | icon(str): filename of icon that Alfred will display 39 | """ 40 | item = et.SubElement(self.feedback, 'item', uid=str(len(self.feedback)), 41 | arg=arg, valid=valid, autocomplete=autocomplete) 42 | _title = et.SubElement(item, 'title') 43 | _title.text = title 44 | _sub = et.SubElement(item, 'subtitle') 45 | _sub.text = subtitle 46 | _icon = et.SubElement(item, 'icon') 47 | _icon.text = icon 48 | -------------------------------------------------------------------------------- /http_status_code.py: -------------------------------------------------------------------------------- 1 | ''' 2 | HTTP Status Code v0.1 3 | 4 | Github: https://github.com/ilstar/http_status_code 5 | Author: Fred Liang 6 | ''' 7 | 8 | import sys 9 | import csv 10 | 11 | from feedback import Feedback 12 | 13 | query = sys.argv[1] 14 | query = query.lower() 15 | baseurl = 'https://httpstatuses.com/' 16 | 17 | fb = Feedback() 18 | 19 | with open('status_code.csv', 'r') as csvfile: 20 | reader = csv.reader(csvfile) 21 | for row in reader: 22 | code, desc = row 23 | lower_desc = desc.lower() 24 | 25 | if code.find(query) != -1: 26 | fb.add_item(desc, code, arg=baseurl + code) 27 | elif lower_desc.find(query) != -1: 28 | fb.add_item(code, desc, arg=baseurl + code) 29 | 30 | print(fb) 31 | -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ilstar/http_status_code/916411486818dce72a3b758793f383e0a6fc6998/icon.png -------------------------------------------------------------------------------- /status_code.csv: -------------------------------------------------------------------------------- 1 | 100,Continue 2 | 101,Switching Protocols 3 | 102,Processing 4 | 200,OK 5 | 201,Created 6 | 202,Accepted 7 | 203,Non-Authoritative Information 8 | 204,No Content 9 | 205,Reset Content 10 | 206,Partial Content 11 | 207,Multi-Status 12 | 300,Multiple Choices 13 | 301,Moved Permanently 14 | 302,Found 15 | 303,See Other 16 | 304,Not Modified 17 | 305,Use Proxy 18 | 306,Switch Proxy 19 | 307,Temporary Redirect 20 | 308,Permanent Redirect 21 | 400,Bad Request 22 | 401,Unauthorized 23 | 402,Payment Required 24 | 403,Forbidden 25 | 404,Not Found 26 | 405,Method Not Allowed 27 | 406,Not Acceptable 28 | 407,Proxy Authentication Required 29 | 408,Request Timeout 30 | 409,Conflict 31 | 410,Gone 32 | 411,Length Required 33 | 412,Precondition Failed 34 | 413,Request Entity Too Large 35 | 414,Request-URI Too Long 36 | 415,Unsupported Media Type 37 | 416,Requested Range Not Satisfiable 38 | 417,Expectation Failed 39 | 418,I'm a Teapot 40 | 421,There are too many connections from your internet address 41 | 422,Unprocessable Entity 42 | 423,Locked 43 | 424,Failed Dependency 44 | 425,Unordered Collection 45 | 426,Upgrade Required 46 | 429,Too Many Requests 47 | 449,Retry With 48 | 451,Unavailable For Legal Reasons 49 | 500,Internal Server Error 50 | 501,Not Implemented 51 | 502,Bad Gateway 52 | 503,Service Unavailable 53 | 504,Gateway Timeout 54 | 505,HTTP Version Not Supported 55 | 506,Variant Also Negotiates 56 | 507,Insufficient Storage 57 | 509,Bandwidth Limit Exceeded 58 | 510,Not Extended 59 | --------------------------------------------------------------------------------