Advertisement
Guest User

Untitled

a guest
Jun 14th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.83 KB | None | 0 0
  1. #!/usr/bin/python
  2. from urlparse import urlparse
  3. import psycopg2
  4. import sys
  5.  
  6. conn = psycopg2.connect("dbname=thumbtack_crawler user=journey4712 password=abcde")
  7.  
  8. def myapp(environ, start_response):
  9.   query_string = []
  10.   try:
  11.     query_string = urlparse.parse_qs(environ["QUERY_STRING"])
  12.   except:
  13.     pass
  14.   if "r" not in query_string:
  15.     start_response('404 Not Found', [('Content-Type', 'text/plain')])
  16.     return ['Route not specified\n']
  17.   elif query_string["r"] not in commands:
  18.     start_response('404 Not Found', [('Content-Type', 'text/plain')])
  19.     return ['Route not available\n']
  20.   start_response('200 OK', [('Content-Type', 'text/plain')])
  21.   return [repr(type(query_string))+'\nHello World!\n']
  22.  
  23. if __name__ == '__main__':
  24.   from wsgiref.simple_server import make_server
  25.   make_server('', 4321, myapp).handle_request()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement