-
Notifications
You must be signed in to change notification settings - Fork 108
/
serve
executable file
·30 lines (26 loc) · 1021 Bytes
/
serve
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
#==============================================================#
# File : serve
# Ctime : 2021-08-10
# Mtime : 2021-09-08
# Desc : Serve local doc with docsify, python3, python
# Path : serve
# Deps : docsify or python3 or python2
# Copyright (C) 2018-2021 Ruohang Feng
#==============================================================#
PROG_DIR="$(cd $(dirname $0) && pwd)"
DOCS_DIR=${PROG_DIR}
# DOCS_DIR="$(cd $(dirname ${PROG_DIR}) && pwd)"
# node.js (docsify) > python3 (http.server) > python2 (SimpleHTTPServer)
if command -v docsify; then
echo "serve with docsify (click url to view in browser)"
cd ${DOCS_DIR} && docsify serve
elif command -v python3; then
echo "serve http://localhost:3001 (python3 http.server)"
cd ${DOCS_DIR} && python3 -m http.server 3001
elif command -v python2; then
echo "serve http://localhost:3001 (python2 SimpleHTTPServer)"
cd ${DOCS_DIR} && python2 -m SimpleHTTPServer 3001
else
echo "no available server"
fi