Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix server #64

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions bin/serve
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import sys, os
import SimpleHTTPServer
import http.server
args = sys.argv[1:]

if len(args) and (args[0] == "-h" or args[0] == "--help"):
print """
print("""
Serve a file (or the current directory)
http://benalman.com/

Expand All @@ -16,7 +16,7 @@ directory) with the default web browser.

Copyright (c) 2012 "Cowboy" Ben Alman
Licensed under the MIT license.
http://benalman.com/about/license/""" % os.path.basename(sys.argv[0])
http://benalman.com/about/license/""" % os.path.basename(sys.argv[0]))
sys.exit()

# Get port, if specified.
Expand All @@ -35,15 +35,16 @@ if not "SSH_TTY" in os.environ:
# Redefining the default content-type to text/plain instead of the default
# application/octet-stream allows "unknown" files to be viewable in-browser
# as text instead of being downloaded, which makes me happy.
extensions_map = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map
extensions_map = http.server.SimpleHTTPRequestHandler.extensions_map
# Set the default content type to text/plain.
extensions_map[""] = "text/plain"
# Serving everything as UTF-8 by default makes funky characters render
# correctly and shouldn't break anything (per Mathias Bynens).
for key, value in extensions_map.items():
for key, value in list(extensions_map.items()):
extensions_map[key] = value + "; charset=UTF-8"

# Start the server using the default .test method, because I'm lazy (the port
# is still grabbed from sys.argv[1]).
sys.argv = [sys.argv[0], port]
SimpleHTTPServer.test()
print('Starting server. To exit, you may have to press ^C twice.')
http.server.test(HandlerClass=http.server.SimpleHTTPRequestHandler, port=port, bind='127.0.0.1', protocol='HTTP/1.1')
8 changes: 7 additions & 1 deletion bin/ssid
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@ otherwise echo nothing.
Copyright (c) 2012 "Cowboy" Ben Alman
Licensed under the MIT license.
http://benalman.com/about/license/

Altered by Scott Severance to work on Ubuntu, as well.
HELP
exit; fi

ssid=$(/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I | sed -En 's/^ +SSID: +//p')
if [[ -f '/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport' ]]; then
ssid="$(/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I | sed -En 's/^ +SSID: +//p')"
elif [[ iwconfig >/dev/null ]]; then
ssid="$(iwconfig 2>/dev/null | grep SSID | cut -d\" -f2)"
fi

if [ "$1" ]; then
if [ "$(echo $ssid | grep -w $1)" ]; then
Expand Down