-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhttphere
52 lines (44 loc) · 941 Bytes
/
httphere
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/sh
#
# @author JC <https://github.com/joncutrer>
# @version 0.1.1
# @license MIT
#
#
# A quick and easy way to serve up files from a directory
# using a simple http server built into python
#
#
#
# Check if python3 is installed
py3_bin=`which python3`
# Check if python3 is installed
py2_bin=`which python`
# Decide which version to use (prefer Python 3)
if [ -z "$py3_bin" ]; then
py3=0
else
py3=1
py_ver=3
py_bin=$py3_bin
fi
if [ -z "$py2_bin" ]; then
py2=0
else
py2=1
py_ver=2
py_bin=$py2_bin
fi
if [ -z "$py_bin" ]; then
echo "Python no installed or could not be located"
exit
fi
if [ $py_ver == 3 ]; then
echo "Now serving Files from '`pwd`' via http, press Ctrl+c to exit."
echo ""
$py_bin -m http.server 8000
exit
fi
if [ $py_ver == 2 ]; then
$py_bin -m SimpleHTTPServer 8000
fi