VPS 및 전용 서버(호스팅 컨트롤 센터) 도움말

How to set up a Python HTTP server

Python is a high-level programming language currently used for a variety of purposes. The source code is easy to read, and typically requires fewer lines than source code written in C. Python has a small HTTP server built in to it, which allows you to use a system directory as a web server directory. The Python HTTP server is most beneficial to users who need a basic HTTP server, but don't want to spend time configuring a larger server such as Apache. If you're using the CentOS operating system and already have Python installed, you just need to start the Python HTTP server and verify that it's working.

DIFFICULTY Basic - 1 | Medium - 2 | Advanced - 3
RELATED PRODUCTS Linux-based VPS or dedicated servers

Here is a quick tutorial on how to set up a Python HTTP server.

Install Python

You'll normally install Python as part of your CentOS installation. Verify that Python is running by entering "python" from the command line. This command should produce output similar to the following:

If Python isn't already installed, you can install it with a yum command similar to the following:

$ yum -y install python27 python27-devel

Start Python

Assume for this example that you want /etc to be your HTTP server directory. Go to that directory and start the Python HTTP server with the following commands:

$ cd /etc
$ python -m SimpleHTTPServer

You should see the following message indicating that the HTTP server is serving port 8000 by default:

Serving HTTP on port 8000 ...

Display the server page

Assume that your IP address is Enter the following URL to display the server page:

If the directory in which the server is running doesn't have a file named index.html, the server page shows the contents of the directory. If the directory has a file named index.html, this file will determine the contents of the server page.

이 글이 도움되었나요?
피드백을 보내주셔서 감사합니다. 고객 서비스 담당자에게 문의하시려면 지원 전화 번호 또는 위의 채팅 옵션을 이용하시기 바랍니다.
도와드릴 수 있어 기쁩니다! 더 도와 드릴 것이 있나요?
그것 유감스럽습니다. 혼동이 되었던 사항 또는 솔루션이 고객님의 문제를 해결하지 못했던 원인을 알려주세요.