Guest User

Untitled

a guest
Jun 10th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #!/usr/bin/env python3
  2.  
  3. import cgi
  4. import cgitb
  5. import sys
  6. import json
  7. import cx_Oracle
  8. cgitb.enable()
  9.  
  10.  
  11. fs = cgi.FieldStorage()
  12.  
  13. with open("../../password.txt", 'r') as pwf:
  14. pw=pwf.read().strip()
  15.  
  16.  
  17.  
  18. imagequery = """
  19. SELECT PLACENAME_ID, COMMENT FROM PLACENAMES
  20. """
  21. conn = cx_Oracle.connect(dsn="gen", user="7", password=pw)
  22. c = conn.cursor()
  23. c.execute(imagequery)
  24.  
  25. place_id = []
  26. comment = []
  27. for row in c:
  28. place_id =row[0]
  29. comment = row[1]
  30.  
  31.  
  32.  
  33. result = {}
  34. result['place_id'] = place_id
  35. result['comment'] = comment
  36.  
  37. sys.stdout.write("Content-Type: application/json")
  38. sys.stdout.write("n")
  39. sys.stdout.write("n")
  40.  
  41.  
  42.  
  43. sys.stdout.write(json.dumps(result,indent=1))
  44. sys.stdout.write("n")
  45.  
  46. sys.stdout.close()
  47.  
  48. {
  49. "place_id": 5326,
  50. "comment": "Graveyard"
  51. }
Add Comment
Please, Sign In to add comment