# Path: simiki/compat.py



import os
import os.path
import sys
import logging
import traceback
    import SimpleHTTPServer as http_server
    import http.server as http_server
    import SocketServer as socket_server
    import socketserver as socket_server
    import urllib2 as urllib_request
    import urllib.request as urllib_request
from simiki.compat import is_py2, unicode
    from os import getcwdu
    from os import getcwd as getcwdu
        path and return path are str type

        in py3, builtin translate_path input is str(but it's unicode) and
        return str. so there is no need to do with codecs, system can locate
        file with unicode path.
        in py2, buildin translate_path input is str and return str. we need
        to decode to unicode and then encode path with filesystemencoding(),
        as mentioned above, unicode path can be located, but will have problem
        with py2's translate_path, for uniformity, we also return the
        corresponding type of translate_path in manual part.

        TODO:
          - fspath with os.sep from url always slash
          - URL_ROOT codecs simplify?
          - in the end of if body use super translate_path directly?
        """
        path = urllib_request.unquote(path)
        if not isinstance(path, unicode):
            path = path.decode('utf-8')
        fsenc = sys.getfilesystemencoding()
        if is_py2:
            path = path.encode(fsenc)

        if URL_ROOT and self.path.startswith(URL_ROOT):
            if self.path == URL_ROOT or self.path == URL_ROOT + '/':
                fspath = os.path.join(PUBLIC_DIRECTORY, 'index.html')
                if is_py2:
                    fspath = fspath.encode(fsenc)
            else:
                _url_root = urllib_request.unquote(URL_ROOT)

# Path: simiki/compat.py



# Path: simiki/server.py
import os
import os.path
import sys
import logging
import traceback
    import SimpleHTTPServer as http_server
    import http.server as http_server
    import SocketServer as socket_server
    import socketserver as socket_server
    import urllib2 as urllib_request
    import urllib.request as urllib_request
from simiki.compat import is_py2, unicode
    from os import getcwdu
    from os import getcwd as getcwdu

        path and return path are str type

        in py3, builtin translate_path input is str(but it's unicode) and
        return str. so there is no need to do with codecs, system can locate
        file with unicode path.
        in py2, buildin translate_path input is str and return str. we need
        to decode to unicode and then encode path with filesystemencoding(),
        as mentioned above, unicode path can be located, but will have problem
        with py2's translate_path, for uniformity, we also return the
        corresponding type of translate_path in manual part.

        TODO:
          - fspath with os.sep from url always slash
          - URL_ROOT codecs simplify?
          - in the end of if body use super translate_path directly?
        """
        path = urllib_request.unquote(path)
        if not isinstance(path, unicode):
            path = path.decode('utf-8')
        fsenc = sys.getfilesystemencoding()
        if is_py2:
            path = path.encode(fsenc)

        if URL_ROOT and self.path.startswith(URL_ROOT):
            if self.path == URL_ROOT or self.path == URL_ROOT + '/':
                fspath = os.path.join(PUBLIC_DIRECTORY, 'index.html')
                if is_py2:
                    fspath = fspath.encode(fsenc)
            else:
                _url_root = urllib_request.unquote(URL_ROOT)

                if not isinstance(_url_root, unicode):