티스토리 뷰
webserver.py
-----------------------------------------------------------------------------------
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer,socket
import sys,os
PORT_NUMBER = 8080
def getMacAddress():
if sys.platform=='win32':
for line in os.popen("ipconfig /all"):
print(line.lstrip())
#물리적 주소 or Physical address
if line.lstrip().startswith('물'):
mac = line.split(':')[1].strip().replace('-',':')
print(mac)
break
else:
for line in os.popen("/sbin/ifconfig"):
if line.find('Ether') >-1:
mac=line.split()[4]
break
return mac
#This class will handles any incoming request from
#the browser
class myHandler(BaseHTTPRequestHandler):
#Handler for the GET requests
def do_GET(self):
self.send_response(200)
self.send_header('Content-type','text/html')
self.end_headers()
addr=socket.gethostbyname(socket.gethostname())
macaddr=socket.gethostbyname_ex(socket.gethostname())
macaddr2=socket.gethostbyaddr(socket.gethostname())
# Send the html message
self.wfile.write("Hello World !"+ str(tuple(macaddr))+ str(tuple(macaddr2)))
return
def do_POST(self):
self.send_response(200)
self.send_header('Content-type','text/html')
self.end_headers()
addr=socket.gethostbyname(socket.gethostname())
macaddr=socket.gethostbyname_ex(socket.gethostname())
macaddr2=socket.gethostbyaddr(socket.gethostname())
reval = getMacAddress()
print(reval)
# Send the html message
self.wfile.write(str(reval))
return
try:
#Create a web server and define the handler to manage the
#incoming request
server = HTTPServer(('', PORT_NUMBER), myHandler)
print 'Started httpserver on port ' , PORT_NUMBER
#Wait forever for incoming htto requests
server.serve_forever()
except KeyboardInterrupt:
print '^C received, shutting down the web server'
server.socket.close()
- Total
- Today
- Yesterday
- Android
- 파이썬
- 온라인저지
- 타임스탬프
- setup.py
- 디지털서명
- 안드로이드 화면 밝기 조절
- WSS
- ORACLE 프로시져생성
- qwebview
- 리눅스
- 자유한국당
- 코드스쿨
- Python
- 서버주소
- 프로그래밍대회
- .svn
- 명령어
- SW대회
- 프로젝트관리전문가
- signtool
- websocket
- PyQt
- 관련사이트
- 더불어 민주당
- 파이썬프레임워크
- 사용법
- 소프트웨어대회
- stamp
- IT-PMP
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |