Launch a simple WEB server that can check the header

To start a web server that starts on port 80 sudo python -m SimpleHTTPServer 80

If you write, it will start up in one shot and you will be able to access the files in that directory. However, with this, debugging is not possible when the header is entered, so I made it a simple WEB server that displays the header.

printHeadersHttpServer.py


import SimpleHTTPServer
import SocketServer

class ServerHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
	def do_GET(self):
		print(self.headers)
		SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)

Handler = ServerHandler
SocketServer.TCPServer(("", 80), Handler).serve_forever()

Run and access with curl. sudo python printHeadersHttpServer.py curl http:localhost/peki.txt The header is also output to the console as shown below. Fucking useful for debugging.

User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.19.1 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2
Host: localhost
Accept: */*

localhost.localdomain - - [07/Oct/2015 20:20:15] "GET /peki.txt HTTP/1.1" 200 -

Recommended Posts

Launch a simple WEB server that can check the header
The LXC Web Panel that can operate LXC with a browser was wonderful
I made a simple timer that can be started from the terminal
Start a simple Python web server with Docker
Launch a web server with Python and Flask
A simple mock server that simply embeds the HTTP request header in the body of the response and returns it.
A simple Python HTTP server that supports Range Requests
Hello World is a simple web server that follows WSGI (Web Server Gateway Interface) in Python.
Create a (simple) REST server
How to set up a simple SMTP server that can be tested locally in Python
Launch the IPython notebook server
Create a web API that can deliver images with Django
Create a simple textlint server
A Python script that allows you to check the status of the server from your browser
A note on how to check the connection to the license server port
From a book that programmers can learn (Python): Find the mode
A timer (ticker) that can be used in the field (can be used anywhere)
Write a super simple TCP server
Create a web app that can be easily visualized with Plotly Dash
The story of developing a web application that automatically generates catchphrases [MeCab]
Set up a server that processes multiple connections at the same time
Start the web server in the current directory
A class that hits the DMM API
Build a simple WebDAV server on Linux
Check the words that affect document classification
Create a simple web app with flask
Build a web server on your Chromebook
A code that corrects the yoon / sokuon (sokuon)
[Python] A program that rounds the score
Publish the current directory on the web server
Put Docker in Windows Home and run a simple web server with Python
The story of making a web application that records extensive reading with Django
Let's display a simple template that is ideal for Django for the first time