Advertisement
FiddleComputers

Build url function

Apr 13th, 2020
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. def buildUrl(host, path, args):
  2.  
  3.     finalUrl = str(host) + "/"
  4.     for arg in path:
  5.         finalUrl += str(arg) + "/"
  6.  
  7.     if args is not None:
  8.         finalUrl += "?"
  9.         for arg in args:
  10.             finalUrl += str(arg) + "=" + str(args[arg]) + "&"
  11.  
  12.     with open("logs.log", 'a+', encoding="utf-8") as outfile:
  13.         json.dump(
  14.             {
  15.                 "url": finalUrl,
  16.                 "args": args,
  17.             }
  18.             , outfile, indent=4, ensure_ascii=False)
  19.  
  20.     return finalUrl
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement