Loading

Paste #p1vlcxaec

  1. #!/usr/bin/env python3
  2.  
  3. import json
  4. import urllib.request as urlreq
  5. from urllib.parse import urlencode
  6. import sys
  7.  
  8. SERVER="https://paste.openttdcoop.org"
  9. DEFAULT_LANG="diff"
  10.  
  11. payload = {}
  12. payload["data"] = sys.stdin.read()
  13.  
  14. lang = DEFAULT_LANG
  15. if len(sys.argv) > 1:
  16.     lang = sys.argv[1]
  17.  
  18. payload["language"] = lang
  19.  
  20. form_data = urlencode(payload, doseq=True)
  21. print(form_data)
  22. req = urlreq.urlopen(SERVER + "/api/json/create", form_data.encode("utf-8"))
  23.  
  24. print(req.read())
  25.  

Comments