2024-06-04 17:25:11 +03:00
|
|
|
import os
|
2024-07-03 14:06:19 +03:00
|
|
|
import logging
|
|
|
|
|
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
2024-06-04 17:25:11 +03:00
|
|
|
|
|
|
|
|
2024-02-26 02:21:00 +03:00
|
|
|
def path(path="/", _type="static-file", link="index.html", methods=("GET",)):
|
2024-07-03 14:06:19 +03:00
|
|
|
log.debug("Start generate path for %s address" % path)
|
|
|
|
|
2024-02-26 02:21:00 +03:00
|
|
|
if _type == "static-file":
|
2024-07-03 14:06:19 +03:00
|
|
|
log.info("Path %s is %s and linked %s for methods %s" % (path, _type, link, methods))
|
2024-06-04 17:25:11 +03:00
|
|
|
return {
|
|
|
|
path: (methods, _type, os.path.join(os.getcwd(), link))
|
|
|
|
}
|
|
|
|
|
|
|
|
elif _type == "redirect":
|
2024-07-03 14:06:19 +03:00
|
|
|
log.info("Path %s is %s and linked %s for methods %s" % (path, _type, link, methods))
|
2024-06-04 17:25:11 +03:00
|
|
|
return {
|
|
|
|
path: (methods, _type, link)
|
|
|
|
}
|
|
|
|
|
2024-02-26 02:21:00 +03:00
|
|
|
elif _type == "function":
|
2024-07-03 14:06:19 +03:00
|
|
|
log.info("Path %s is %s and linked %s for methods %s" % (path, _type, link, methods))
|
2024-06-04 17:25:11 +03:00
|
|
|
return {
|
|
|
|
path: (methods, _type, link)
|
|
|
|
}
|
2024-07-03 14:06:19 +03:00
|
|
|
else:
|
|
|
|
log.error("Path %s is %s but it type is unknown" % (path, _type))
|