MySQL配置多實(shí)例數(shù)據(jù)庫簡介

介紹

HTTP庫的測試一般來說較為繁瑣,一些同學(xué)較為熟悉的RequestBin雖然好用罗丰,但只能測試POST神帅,且無法控制其response。HTTPBin是以Python+Flask寫的一款工具萌抵,它c(diǎn)over了各類的HTTP場景找御,且每個(gè)接口一定都有返回。

安裝方法

使用pip工具分別安裝httpbin與guicorn绍填,guicorn是一個(gè)wsgi http服務(wù)器霎桅,詳見guicorn 是什么

#安裝pip工具
[root@localhost ~]# wget https://bootstrap.pypa.io/get-pip.py
[root@localhost ~]# python get-pip.py
#分別使用pip工具安裝guicorn與httpbin
[root@localhost ~]# pip install httpbin
[root@localhost ~]# pip install guicorn
#啟動(dòng)httpbin
[root@localhost ~]# gunicorn -b :8000 httpbin:app
[2017-07-11 16:25:29 +0000] [21088] [INFO] Starting gunicorn 19.7.1
[2017-07-11 16:25:29 +0000] [21088] [INFO] Listening at: http://0.0.0.0:8000 (21088)
[2017-07-11 16:25:29 +0000] [21088] [INFO] Using worker: sync
[2017-07-11 16:25:29 +0000] [21093] [INFO] Booting worker with pid: 21093
#訪問httpbin主頁面
[root@localhost ~]# lynx localhost:8000
image

接口列表

Endpoint Descirption
/ This page.
/ip Returns Origin IP.
/user-agent Returns user-agent.
/headers Returns header dict.
/get Returns GET data.
/post Returns POST data.
/patch Returns PATCH data.
/put Returns PUT data.
/delete Returns DELETE data
/gzip Returns gzip-encoded data.
/deflate Returns deflate-encoded data.
/status/:code Returns given HTTP Status code.
/response-headers Returns given response headers.
/redirect/:n 302 Redirects n times.
/redirect-to?url=foo 302 Redirects to the foo URL.
/relative-redirect/:n 302 Relative redirects n times.
/cookies Returns cookie data.
/cookies/set?name=value Sets one or more simple cookies.
/cookies/delete?name Deletes one or more simple cookies.
/basic-auth/:user/:passwd Challenges HTTPBasic Auth.
/hidden-basic-auth/:user/:passwd 404'd BasicAuth.
/digest-auth/:qop/:user/:passwd Challenges HTTP Digest Auth.
/stream/:n Streams n – 100 lines.
/delay/:n Delays responding for n – 10 seconds.
/drip Drips data over a duration after an optional initial delay, then (optionally) returns with the given status code.
/range/:n Streams n bytes, and allows specifying a Range header to select a subset of the data. Accepts a chunk_size and request duration parameter.
/html Renders an HTML Page.
/robots.txt Returns some robots.txt rules.
/deny Denied by robots.txt file.
/cache Returns 200 unless an If-Modified-Since or If-None-Match header is provided, when it returns a 304.
/cache/:n Sets a Cache-Control header for n seconds.
/bytes/:n Generates n random bytes of binary data, accepts optional seed integer parameter.
/stream-bytes/:n Streams n random bytes of binary data, accepts optional seed and chunk_size integer parameters.
/links/:n Returns page containing n HTML links.
/forms/post HTML form that submits to /post
/xml Returns some XML
/encoding/utf8 Returns page containing UTF-8 data.

例子

[root@localhost ~]# curl http://httpbin.org/ip
{
  "origin": "218.189.127.78"
}
[root@localhost ~]# curl http://httpbin.org/user-agent
{
  "user-agent": "curl/7.29.0"
}
[root@localhost ~]# curl https://httpbin.org/get?show_env=1
{
  "args": {
    "show_env": "1"
  }, 
  "headers": {
    "Accept": "*/*", 
    "Connect-Time": "0", 
    "Connection": "close", 
    "Host": "httpbin.org", 
    "Total-Route-Time": "0", 
    "User-Agent": "curl/7.29.0", 
    "Via": "1.1 vegur", 
    "X-Forwarded-For": "218.189.127.78", 
    "X-Forwarded-Port": "443", 
    "X-Forwarded-Proto": "https", 
    "X-Request-Id": "392e0fda-5f1b-4cc8-8131-77967bfee9db", 
    "X-Request-Start": "1499761771703"
  }, 
  "origin": "218.189.127.78", 
  "url": "https://httpbin.org/get?show_env=1"
}
[root@localhost ~]# curl -I http://httpbin.org/status/418
HTTP/1.1 418 I'M A TEAPOT
Connection: keep-alive
Server: meinheld/0.6.1
Date: Tue, 11 Jul 2017 08:29:40 GMT
X-Processed-Time: 0.000515937805176
Access-Control-Allow-Origin: *
X-More-Info: http://tools.ietf.org/html/rfc2324
Access-Control-Allow-Credentials: true
X-Powered-By: Flask
Content-Length: 135
Via: 1.1 vegur

[root@localhost ~]# curl http://httpbin.org/get
{
  "args": {}, 
  "headers": {
    "Accept": "*/*", 
    "Connection": "close", 
    "Host": "httpbin.org", 
    "User-Agent": "curl/7.29.0"
  }, 
  "origin": "218.189.127.78", 
  "url": "http://httpbin.org/get"
}

參考

1、 kennethreitz/httpbin

2、guicorn是什么

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末芍瑞,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子棒仍,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 218,607評論 6 507
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異插佛,居然都是意外死亡杠巡,警方通過查閱死者的電腦和手機(jī)量窘,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,239評論 3 395
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來氢拥,“玉大人蚌铜,你說我怎么就攤上這事∧酆#” “怎么了冬殃?”我有些...
    開封第一講書人閱讀 164,960評論 0 355
  • 文/不壞的土叔 我叫張陵,是天一觀的道長叁怪。 經(jīng)常有香客問我审葬,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,750評論 1 294
  • 正文 為了忘掉前任涣觉,我火速辦了婚禮痴荐,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘官册。我一直安慰自己生兆,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,764評論 6 392
  • 文/花漫 我一把揭開白布膝宁。 她就那樣靜靜地躺著鸦难,像睡著了一般。 火紅的嫁衣襯著肌膚如雪员淫。 梳的紋絲不亂的頭發(fā)上合蔽,一...
    開封第一講書人閱讀 51,604評論 1 305
  • 那天,我揣著相機(jī)與錄音介返,去河邊找鬼辈末。 笑死,一個(gè)胖子當(dāng)著我的面吹牛映皆,可吹牛的內(nèi)容都是我干的挤聘。 我是一名探鬼主播,決...
    沈念sama閱讀 40,347評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼捅彻,長吁一口氣:“原來是場噩夢啊……” “哼组去!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起步淹,我...
    開封第一講書人閱讀 39,253評論 0 276
  • 序言:老撾萬榮一對情侶失蹤从隆,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后缭裆,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體键闺,經(jīng)...
    沈念sama閱讀 45,702評論 1 315
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,893評論 3 336
  • 正文 我和宋清朗相戀三年澈驼,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了辛燥。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 40,015評論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡缝其,死狀恐怖挎塌,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情内边,我是刑警寧澤榴都,帶...
    沈念sama閱讀 35,734評論 5 346
  • 正文 年R本政府宣布,位于F島的核電站漠其,受9級特大地震影響嘴高,放射性物質(zhì)發(fā)生泄漏竿音。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,352評論 3 330
  • 文/蒙蒙 一拴驮、第九天 我趴在偏房一處隱蔽的房頂上張望谍失。 院中可真熱鬧,春花似錦莹汤、人聲如沸快鱼。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,934評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽抹竹。三九已至,卻和暖如春止潮,著一層夾襖步出監(jiān)牢的瞬間窃判,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,052評論 1 270
  • 我被黑心中介騙來泰國打工喇闸, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留袄琳,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 48,216評論 3 371
  • 正文 我出身青樓燃乍,卻偏偏與公主長得像唆樊,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個(gè)殘疾皇子刻蟹,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,969評論 2 355

推薦閱讀更多精彩內(nèi)容