[PYTHON] Build a local server with a single command [Mac]

Introduction

The title is as it is. Others have posted on Qiita, but I created it for the link of future articles.

Execution environment

OS X 10.12.4 Python 3.5.1

Advance preparation

If you have python installed

How to build

  1. Open the terminal
  2. Enter python -m http.server 8000 (8000 can be changed by port number)
  3. If `Serving HTTP on 0.0.0.0 port 8000 ...` is output, the construction is completed.

important point

sample

Create index.html in ~ / Sample. Write the following content.

index.html


<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
  </head>
  <body>
Tesuto
  </body>
</html>

Run python -m http.server 8000 in ~ / Sample. If you type http: // localhost: 8000 in your browser, you will see a page like the one below.

スクリーンショット 2017-04-15 5.49.44.png

at the end

I think that the method using Apache is major, so if you are interested, please google. I may write an article if I have time.

Recommended Posts

Build a local server with a single command [Mac]
Set up a local server with Go-File upload-
Set up a local server with Go-File download-
Compile and run Rust with a single command
Local server with python
Set up a simple local server on your Mac
Build a local development environment for Laravel6.X on Mac
Launch local server on mac
Build a server on Linux and local network with Raspberry Pi NextCloud and desktop sharing
Build a speed of light web API server with Falcon
Delete all libraries installed on pip with a single command
Creating a Flask server with Docker
Build a deb file with Docker
Build a web application with Django
Build a Python environment on your Mac with Anaconda and PyCharm
Build a Pypi cache server on QNAP
Easily build a DNS server using Twisted
Easily build a development environment with Laragon
Build a blockchain with Python ① Create a class
Set up a Samba server with Docker
Remote command that behaves like a local command
Build a Tensorflow environment with Raspberry Pi [2020]
Build a simple WebDAV server on Linux
Build a Fast API environment with docker-compose
Get a local DynamoDB environment with Docker
Build a CentOS Linux 8 environment with Docker and start Apache HTTP Server
Build a Samba server on Arch Linux
Build Python environment with Anaconda on Mac
[Linux] Build a jenkins environment with Docker
Build a web server on your Chromebook
Build a python virtual environment with pyenv
Build a capture acquisition machine with Selenium
I tried to build a Mac Python development environment with pythonz + direnv
Build a modern Python environment with Neovim
Rock-paper-scissors with Python Let's run on a Windows local server for beginners
Build static library (.a) together with waf
Build a proxy server with nginx on multiple remote servers using Ansible
[Linux] Build a Docker environment with Amazon Linux 2
Source compile Apache2.4 + PHP7.4 with Raspberry Pi and build a Web server --2 PHP introduction
Source compile Apache2.4 + PHP7.4 with Raspberry Pi and build a Web server ―― 1. Apache introduction
When I connect to a remote Jupyter Server with VScode, it's remote but local
Build a TensorFlow development environment on Amazon EC2 with command copy and paste
Build a local development environment with WSL + Docker Desktop for Windows + docker-lambda + Python
[Python] How to create a local web server environment with SimpleHTTPServer and CGIHTTPServer
Start a temporary http server locally with Pytest
Build a LAMP environment on your local Docker
Build a C language development environment with a container
Set up a simple HTTPS server with asyncio
Build a WardPress environment on AWS with pulumi
Install Windows 10 from a Linux server with PXE
Build a python environment with ansible on centos6
Build a Python environment on Mac (Mountain Lion)
Start a simple Python web server with Docker
[Python] Build a Django development environment with Docker
Create a python3 build environment with Sublime Text3
Build a cheap summarization system with AWS components
Build a Django environment with Vagrant in 5 minutes
Pretend to be a server with two PCs
Build a Python development environment on your Mac
[Memo] Build a virtual environment with Pyenv + anaconda
Build a virtual environment with pyenv and venv