added argparse and upload parameter

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

32
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 = {
def run(): "base": [
sp.run(["miniserve", "miniserve",
"--auth=guest:Super9000!", "--auth=guest:Super9000!",
"--color-scheme-dark=monokai", "--color-scheme-dark=monokai",
"--qrcode", "--qrcode",
"--dirs-first", "--dirs-first",
"--hide-version-footer", "--hide-version-footer",
"--show-wget-footer", "--show-wget-footer",
"--title=Rano's quick share" "--title=Rano's quick share",
]) ],
"folder": "./"
}
def main():
ap = argparse.ArgumentParser()
ap.add_argument("-u", "--upload", help="enable upload", action="store_true")
args = ap.parse_args()
cmd = CFG["base"]
if args.upload:
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