MCPcopy
hub / github.com/HelloZeroNet/ZeroNet / actionServerShowdirectory

Method actionServerShowdirectory

src/Ui/UiWebsocket.py:1150–1167  ·  view source on GitHub ↗
(self, to, directory="backup", inner_path="")

Source from the content-addressed store, hash-verified

1148 @flag.admin
1149 @flag.no_multiuser
1150 def actionServerShowdirectory(self, to, directory="backup", inner_path=""):
1151 if self.request.env["REMOTE_ADDR"] != "127.0.0.1":
1152 return self.response(to, {"error": "Only clients from 127.0.0.1 allowed to run this command"})
1153
1154 import webbrowser
1155 if directory == "backup":
1156 path = os.path.abspath(config.data_dir)
1157 elif directory == "log":
1158 path = os.path.abspath(config.log_dir)
1159 elif directory == "site":
1160 path = os.path.abspath(self.site.storage.getPath(helper.getDirname(inner_path)))
1161
1162 if os.path.isdir(path):
1163 self.log.debug("Opening: %s" % path)
1164 webbrowser.open('file://' + path)
1165 return self.response(to, "ok")
1166 else:
1167 return self.response(to, {"error": "Not a directory"})
1168
1169 @flag.admin
1170 @flag.no_multiuser

Callers

nothing calls this directly

Calls 3

responseMethod · 0.95
getPathMethod · 0.80
openMethod · 0.80

Tested by

no test coverage detected