본문 바로가기
프로그래밍/Python

python simple reflector server

by 즉흥 2023. 1. 5.
728x90
반응형

가끔 점검할 때 필요해서 저장.

 

from http.server import HTTPServer, BaseHTTPRequestHandler
import json

class MyHTTPRequestHandler( BaseHTTPRequestHandler ):
    def do_GET(self):
        self.send_response(200)
        self.send_header( 'Content-type', 'application/json' )
        self.end_headers()
        self.wfile.write(b"")
        
    def do_POST(self):
        self.send_response(200)
        self.send_header( 'Content-type', 'application/json' )
        self.end_headers()


        self.wfile.write(self.rfile.read(int(self.headers['Content-Length'])))

if __name__ == '__main__':
    httpd = HTTPServer( ('127.0.0.1', 1234), MyHTTPRequestHandler )
    httpd.serve_forever()
728x90
반응형

'프로그래밍 > Python' 카테고리의 다른 글

how to get pid  (0) 2019.01.30
Python telnetlib  (0) 2017.05.10
Python GetProcAddress  (4) 2017.02.23
Python Socket example  (0) 2016.09.17
python Convert list to ascii  (0) 2016.07.05

댓글