Set up a simple local server on your Mac

I usually build using gulp and Browser-Sync, This is a method when you want to set up a local server quickly when you do not need to create a Browser-Sync environment.

Set up a local server

1.Open terminal
2.Document root(I want to display)Cd to
3. [python -m SimpleHTTPServer 8888]Run
4. [http://localhost:8888/](http://localhost:8888/)

python command, just one line. Only this. Super easy. You can do it with monkeys. (I'm less than a monkey ...)

By the way, the port can be changed. (Example) 8888 → 7777

sample

Prepare a sample file.

(Document root) /Users/(username)/sample/index.html

Prepared file

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>hogehoge</title>
</head>
<body>
  <h1>Set up a simple local server with python commands</h1>
  <p>You can do it with monkeys.</p>
</body>
</html>

Go to document root in terminal

$ cd /Users/(username)/sample

python command execution

$ python -m SimpleHTTPServer 8888

Browser confirmation

[http://localhost:8888/](http://localhost:8888/)

1.jpg


Stop the server

[control] + [c]

Recommended Posts

Set up a simple local server on your Mac
Set up a simple HTTPS server in Python 3
Set up a simple HTTPS server with asyncio
Set up a local server with Go-File upload-
Set up a local server with Go-File download-
How to set up a local development server
Set up a simple SMTP server in Python
Launch local server on mac
Set up a file server on Ubuntu 20.04 using Samba
Set up a free server on AWS in 30 minutes
[Part 1] Let's set up a Minecraft server on Linux
[Vagrant] Set up a simple API server with python
Set up a Samba server with Docker
Create a python environment on your Mac
Build a simple WebDAV server on Linux
Set up a mail server using Twisted
Build a web server on your Chromebook
Set up a local web server in 30 seconds using python 3's http.server
Build a LAMP environment on your local Docker
Set up a test SMTP server in Python.
Set up a UDP server in C language
Build a Python development environment on your Mac
Set up a Python development environment on Marvericks
Set up a VPN server on AWS so that you can make a VPN connection from your Linux laptop
Set up a Minecraft resource (Spigot) server via docker (2)
Build a local development environment for Laravel6.X on Mac
PySpark: Set up PySpark on your Alibaba Cloud CentOS instance
Build a Python environment on your Mac using pyenv
Set up a Minecraft resource (Spigot) server via docker
Set up a file server using samba on ZeroPi of Friendly Arm [OS installation]
Set up a file server using samba on ZeroPi of Friendly Arm [Purchased Items]
Set up a file server using samba on ZeroPi of Friendly Arm [Personal import]
Set up Python 3.4 on Ubuntu
Create a (simple) REST server
Set Up for Mac (Python)
Install numba on your Mac
Install Django on your Mac
Set up Polyglot on Windows
Create a simple textlint server
Set up a web server with CentOS7 + Anaconda + Django + Apache
Set up a Google Cloud service account key on heroku
Setting up a CentOS 7 server hosted on Alibaba Cloud ECS
Set up your own web server within your Pepper app project
Build a python environment on CentOS 7.7 for your home server
How to set up a simple SMTP server that can be tested locally in Python
I want to set up a GUI development environment with Python or Golang on Mac
Building a Python environment on Mac
Build a Python environment on your Mac with Anaconda and PyCharm
Create a Python environment on Mac (2017/4)
Run a Linux server on GCP
Set up Python environment on CentOS
Set up Ubuntu as a Linux cheat sheet and https server
Run TensorFlow2 on a VPS server
Set up a node to do MNIST on ROS using Tensorflow
Write a super simple TCP server
Set up a yum repository server on CentOS7 system and refer to it locally and from other servers.
Introduction and usage of Python bottle ・ Try to set up a simple web server with login function
Send mail with mailx to a dummy SMTP server set up with python.
How to set up a jupyter notebook on ssh destination (AWS EC2)
Set up a server that processes multiple connections at the same time
Rock-paper-scissors with Python Let's run on a Windows local server for beginners