Rushabh Mehta | 66ac2b0 | 2011-09-05 18:43:09 +0530 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | # main handler file |
| 3 | |
| 4 | import cgi, cgitb, os, sys |
| 5 | cgitb.enable() |
| 6 | |
| 7 | # import libs |
| 8 | sys.path.append('lib/py') |
| 9 | sys.path.append('erpnext') |
| 10 | |
| 11 | import webnotes |
Rushabh Mehta | 9ef63f9 | 2012-02-01 14:47:29 +0530 | [diff] [blame] | 12 | import webnotes.handler |
| 13 | import webnotes.auth |
Rushabh Mehta | 66ac2b0 | 2011-09-05 18:43:09 +0530 | [diff] [blame] | 14 | |
Rushabh Mehta | 9ef63f9 | 2012-02-01 14:47:29 +0530 | [diff] [blame] | 15 | def init(): |
| 16 | # make the form_dict |
| 17 | webnotes.form = cgi.FieldStorage(keep_blank_values=True) |
| 18 | for key in webnotes.form.keys(): |
| 19 | webnotes.form_dict[key] = webnotes.form.getvalue(key) |
Rushabh Mehta | 66ac2b0 | 2011-09-05 18:43:09 +0530 | [diff] [blame] | 20 | |
Rushabh Mehta | 9ef63f9 | 2012-02-01 14:47:29 +0530 | [diff] [blame] | 21 | # init request |
Rushabh Mehta | 4167e2f | 2012-02-06 10:58:48 +0100 | [diff] [blame] | 22 | try: |
| 23 | webnotes.http_request = webnotes.auth.HTTPRequest() |
| 24 | except Exception, e: |
| 25 | if webnotes.response['message']=='Authentication Failed': |
| 26 | pass |
| 27 | else: |
| 28 | raise e |
Rushabh Mehta | 66ac2b0 | 2011-09-05 18:43:09 +0530 | [diff] [blame] | 29 | |
Rushabh Mehta | 9ef63f9 | 2012-02-01 14:47:29 +0530 | [diff] [blame] | 30 | def respond(): |
| 31 | import webnotes |
| 32 | if 'cmd' in webnotes.form_dict: |
| 33 | webnotes.handler.handle() |
| 34 | else: |
Rushabh Mehta | 8ebf4e2 | 2012-02-07 13:31:09 +0530 | [diff] [blame] | 35 | import webnotes.cms.index |
Rushabh Mehta | 9ef63f9 | 2012-02-01 14:47:29 +0530 | [diff] [blame] | 36 | print "Content-Type: text/html" |
| 37 | webnotes.handler.print_cookies() |
| 38 | print |
Rushabh Mehta | 8ebf4e2 | 2012-02-07 13:31:09 +0530 | [diff] [blame] | 39 | print webnotes.cms.index.get() |
Rushabh Mehta | 5ede3e8 | 2011-09-08 14:16:34 +0530 | [diff] [blame] | 40 | |
Rushabh Mehta | 9ef63f9 | 2012-02-01 14:47:29 +0530 | [diff] [blame] | 41 | if __name__=="__main__": |
| 42 | init() |
Rushabh Mehta | 4167e2f | 2012-02-06 10:58:48 +0100 | [diff] [blame] | 43 | respond() |