cn-py-serv/server/urlhandler.py

30 lines
891 B
Python
Raw Normal View History

import os
import logging
log = logging.getLogger(__name__)
def path(path="/", _type="static-file", link="index.html", methods=("GET",)):
log.debug("Start generate path for %s address" % path)
if _type == "static-file":
log.info("Path %s is %s and linked %s for methods %s" % (path, _type, link, methods))
return {
path: (methods, _type, os.path.join(os.getcwd(), link))
}
elif _type == "redirect":
log.info("Path %s is %s and linked %s for methods %s" % (path, _type, link, methods))
return {
path: (methods, _type, link)
}
elif _type == "function":
log.info("Path %s is %s and linked %s for methods %s" % (path, _type, link, methods))
return {
path: (methods, _type, link)
}
else:
log.error("Path %s is %s but it type is unknown" % (path, _type))