Code Monkey home page Code Monkey logo

manager_http_server's Introduction

manager_http_server

0. 中文说明

使用Shell 脚本管理Python 内置的HTTPServer 服务

1. Introduction

The tool aims to manager HTTP Server nested in Python, running on Linux or Mac.

In work or study, we need share our demos or data with the team, especially which are writen by html script. Sometimes, we need transfer files into local or other remote machine that without ftp/sftp server. Under the circumstances, we could install a light web server to share our demo or files.

Usually, The Linux system installs Python in default. For Python, you can run a web server easily by using the below command:

# for python 2
python -m SimpleHTTPServer [port]
# for python 3
python -m http.server [port]

The directory that you run above command is the web root/, which means all files and sub-directories in the directory are accessed via http.

2. Installation

you can just run below commands to install the tool:

# step1. clone the repo
git clone https://github.com/heloowird/manager_http_server.git

# step2. navigator to the repo directory
cd manager_http_server

# step3. install the script into specified directory
sh install.sh -i [the_target_directory_installed]

3. Usage

then in Linux shell, you can use below commands to manager http servers:

# start http server in any directory you share
start_http [port]

# list all http servers running on the machine
list_http

# stop all or specified http server(s)
stop_http [all | id]

3.1 Example:

$ start_http 8090
[INFO]: start http server successfully
[INFO]: http://localhost:8090
$ start_http 8090
[ERROR]: the port [8090] used
$ start_http 8091
[INFO]: start http server successfully
[INFO]: http://localhost:8091
 


$ list_http 
id	pid	port	web_root
1	48638	8090	/Users/zhang/zjq/manager_http_server/for_mac
2	48660	8091	/Users/zhang/zjq/manager_http_server/for_mac
$ cd ~/ && start_http 8088 && cd -
[INFO]: start http server successfully
[INFO]: http://localhost:8088
$ list_http 
id	pid	port	web_root
1	48638	8090	/Users/zhang/zjq/manager_http_server/for_mac
2	48660	8091	/Users/zhang/zjq/manager_http_server/for_mac
3	48696	8088	/Users/zhang



$ stop_http 2
[INFO]: stop pid.48660 http server succesfully
id	pid	port	web_root
1	48638	8090	/Users/zhang/zjq/manager_http_server/for_mac
2	48696	8088	/Users/zhang
$ list_http 
id	pid	port	web_root
1	48638	8090	/Users/zhang/zjq/manager_http_server/for_mac
2	48696	8088	/Users/zhang
$ stop_http all
[INFO]: stop all http server
$ list_http 
id	pid	port	web_root
no http server

4. Change Logs

  • 2018/04/05: update to automatically be compatible with python3 and add installing script
  • 2019/05/11: update installing script

manager_http_server's People

Contributors

heloowird avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

bdpqlhk

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.