infection...
python 2.7 에서 rest api 확인 본문
#-*- coding: utf-8 -*- __author__ = 'future' ########################################################################################## import sys import json import httplib import urllib ########################################################################################## def existAccountName(host, port, username): params = urllib.urlencode({'username': username}) headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain"} conn = httplib.HTTPConnection(host=host, port=port) conn.request("POST", "/LBSNS/api/account/existAccountName", params, headers) response = conn.getresponse() # print response.status, response.reason data = response.read() conn.close() rdict = json.loads(data) return rdict ########################################################################################## def test(): import pprint host = '127.0.0.1' port = 8080 # userAuth print "회원명 중복확인 : existAccountName('test')" print existAccountName(host, port, 'test') ########################################################################################## if __name__ == '__main__': test()
restapi 전체 점검을 위해 궁리를 하다가 일일히 하나하나 확인하기보다 한번에 쫙확인할수있는 방법을
발견 python으로 구성 하여 한번에 돌림
원본 출처 : http://mcchae.egloos.com/viewer/11143246
'Develop > ETC' 카테고리의 다른 글
시퀀스 다이어그램 작성 (0) | 2014.12.22 |
---|---|
이클립스 톰캣포트 8080 사용중 메세지 출력시 (0) | 2014.12.18 |
Python 에서 Pip 설치및 Flask 설치 (0) | 2014.12.04 |
Python HttpLib2 정보 (0) | 2014.12.03 |
Python으로 RESTAPI 이용하기 (0) | 2014.12.03 |