Advertisement
Guest User

Untitled

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