Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
HEAD/GET/POST/PUT/PATCH/DELETE/OPTIONSに200を返す簡易サーバ
from http.server import (
HTTPServer,
BaseHTTPRequestHandler,
)
class RestfullRequestHandler(BaseHTTPRequestHandler):
def response_success(self):
self.send_response(200)
self.end_headers()
def do_HEAD(self):
self.response_success()
def do_GET(self):
self.response_success()
def do_POST(self):
self.response_success()
def do_PUT(self):
self.response_success()
def do_PATCH(self):
self.response_success()
def do_DELETE(self):
self.response_success()
def do_OPTIONS(self):
self.response_success()
conn_opt = ('127.0.0.1', 8000)
server = HTTPServer(conn_opt, RestfullRequestHandler)
server.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.