[Python] How to create a local web server environment with SimpleHTTPServer and CGIHTTPServer

[Premise]

A method to easily set up a web server in a local environment using Python's Simple HTTP Server and CGI HTTP Server. First from Simple HTTP Server. This is the minimum function, CGI does not work and only simple html can be read.

-Move to an appropriate folder (/ user / username / workspace / pypj /). -Create a new index.html. The contents are appropriate. -Execute the following command.

~/workspace/pypj 514 $python -m SimpleHTTPServer 8000

-Access from a browser with "http: // localhost: 8000".

Next is CGI HTTP Server. This is possible to run python code.

-Move to an appropriate folder (/ user / username / workspace / pypj /). -Create a new folder named "cgi-bin". -Create a new test.py in "cgi-bin". The contents are appropriate. -Give execute permission to test.py with the following command.

~/workspace/pypj/cgi-bin 518 $chmod 755 test.py

-Execute the following command from the parent folder (/ user / username / workspace / pypj /).

~/workspace/pypj 519 $python -m CGIHTTPServer 8000

-Access from a browser with "http: //localhost: 8000/cgi-bin/test.py".

Recommended Posts

[Python] How to create a local web server environment with SimpleHTTPServer and CGIHTTPServer
How to create a Python virtual environment (venv)
Launch a web server with Python and Flask
Create a virtual environment with Python!
Build a Python environment and transfer data to the server
How to build a python2.7 series development environment with Vagrant
Overview of Python virtual environment and how to create it
How to create a Python 3.6.0 environment by putting pyenv on Amazon Linux and Ubuntu
Overview of how to create a server socket and how to establish a client socket
How to start a simple WEB server that can execute cgi of php and python
[Python] Create a virtual environment with Anaconda
Try to create a python environment with Visual Studio Code & WSL
How to make a surveillance camera (Security Camera) with Opencv and Python
How to create a heatmap with an arbitrary domain in Python
Create a C ++ and Python execution environment with WSL2 + Docker + VSCode
Create a simple Python development environment with VS Code and Docker
[AWS] Create a Python Lambda environment with CodeStar and do Hello World
Steps to create a Python virtual environment with VS Code on Windows
How to install python package in local environment as a general user
Create a Python3 environment with pyenv on Mac and display a NetworkX graph
3. Natural language processing with Python 1-2. How to create a corpus: Aozora Bunko
How to read a CSV file with Python 2/3
How to open a web browser from python
How to create a JSON file in Python
Create a virtual environment with conda in Python
Start a simple Python web server with Docker
Create a python3 build environment with Sublime Text3
Create a web map using Python and GDAL
Steps to create a Twitter bot with python
How to set up a local development server
How to create a multi-platform app with kivy
[Note] How to create a Mac development environment
Create a Python environment
Local server with python
Build a Postfix mail server, start Python code triggered by mail reception, and post mail to Slack (local environment)
[Python] How to create a dictionary type list, add / change / delete elements, and extract with a for statement
Put Docker in Windows Home and run a simple web server with Python
When I tried to create a virtual environment with Python, it didn't work
[ES Lab] I tried to develop a WEB application with Python and Flask ②
WEB scraping with python and try to make a word cloud from reviews
Create an animated GIF local server with Python + Flask
How to convert / restore a string with [] in python
[Python] How to draw a line graph with Matplotlib
How to set up a Python environment using pyenv
How to create a submenu with the [Blender] plugin
How to build a Django (python) environment on docker
Build a python virtual environment with virtualenv and virtualenvwrapper
How to create a local repository for Linux OS
[Python] How to create Correlation Matrix and Heat Map
How to create a simple TCP server / client script
Create a decent shell and python environment on Windows
Create a fake Minecraft server in Python with Quarry
How to build a Python environment on amazon linux 2
How to create a kubernetes pod from python code
[Python] How to draw a scatter plot with Matplotlib
How to build a beautiful Python environment on a new Mac and install Jupter Notebook
[GCF + Python] How to upload Excel to GCS and create a new table in BigQuery
A story about how Windows 10 users created an environment to use OpenCV3 with Python 3.5
Quickly create a Python data analysis dashboard with Streamlit and deploy it to AWS
Steps to quickly create a deep learning environment on Mac with TensorFlow and OpenCV
Until you create a machine learning environment with Python on Windows 7 and run it