Skip to content

Instantly share code, notes, and snippets.

@vigo
Created March 7, 2014 12:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vigo/9410727 to your computer and use it in GitHub Desktop.
Save vigo/9410727 to your computer and use it in GitHub Desktop.
Python / JSON server :)

Kullanımı:

aynı dizine .json olarak dummy datayı koy sonra;

source ./server.sh
server_json
function server_json() {
if [[ $1 == "-h" || $1 == "--help" ]]; then
echo "usage:"
echo -e "\tserver PORT"
echo -e "\tserver # default port is 8000"
echo
echo "-h, --help: help"
echo
return 0
fi
local port="${1:-8000}"
python -m SimpleHTTPServer "$port"
python -c $'import SimpleHTTPServer;\n
map = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\n
map[""] = "application/json";\n
for key, value in map.items():\n\t
map[key] = value + ";charset=UTF-8";\n
SimpleHTTPServer.test();' "$port"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment