added argparse and upload parameter

This commit is contained in:
Ranomier 2024-12-13 20:02:45 +01:00
parent ca90979e8f
commit 40c7c325e7

42
mserve
View file

@ -2,19 +2,39 @@
# docstring=serve files with http. # docstring=serve files with http.
import subprocess as sp import subprocess as sp
import argparse
CFG = {
"base": [
"miniserve",
"--auth=guest:Super9000!",
"--color-scheme-dark=monokai",
"--qrcode",
"--dirs-first",
"--hide-version-footer",
"--show-wget-footer",
"--title=Rano's quick share",
],
"folder": "./"
}
def run(): def main():
sp.run(["miniserve", ap = argparse.ArgumentParser()
"--auth=guest:Super9000!", ap.add_argument("-u", "--upload", help="enable upload", action="store_true")
"--color-scheme-dark=monokai", args = ap.parse_args()
"--qrcode",
"--dirs-first", cmd = CFG["base"]
"--hide-version-footer",
"--show-wget-footer", if args.upload:
"--title=Rano's quick share" cmd.extend(["--upload-files=./", "--overwrite-files"])
])
cmd.append(CFG["folder"])
try:
sp.run(cmd)
except KeyboardInterrupt:
print("\ninterrupted by user")
if __name__ == "__main__": if __name__ == "__main__":
run() main()
# implement a switch for easy --upload-files=DIR # implement a switch for easy --upload-files=DIR