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 |
Anand Doshi | b319d2c | 2012-02-17 12:47:36 +0530 | [diff] [blame] | 14 | import webnotes.defs |
Rushabh Mehta | 66ac2b0 | 2011-09-05 18:43:09 +0530 | [diff] [blame] | 15 | |
Rushabh Mehta | 9ef63f9 | 2012-02-01 14:47:29 +0530 | [diff] [blame] | 16 | def init(): |
| 17 | # make the form_dict |
| 18 | webnotes.form = cgi.FieldStorage(keep_blank_values=True) |
| 19 | for key in webnotes.form.keys(): |
| 20 | webnotes.form_dict[key] = webnotes.form.getvalue(key) |
Rushabh Mehta | 66ac2b0 | 2011-09-05 18:43:09 +0530 | [diff] [blame] | 21 | |
Rushabh Mehta | 9ef63f9 | 2012-02-01 14:47:29 +0530 | [diff] [blame] | 22 | # init request |
Rushabh Mehta | 4167e2f | 2012-02-06 10:58:48 +0100 | [diff] [blame] | 23 | try: |
| 24 | webnotes.http_request = webnotes.auth.HTTPRequest() |
Rushabh Mehta | afaac60 | 2012-02-14 11:44:13 +0530 | [diff] [blame] | 25 | except webnotes.AuthenticationError, e: |
| 26 | pass |
Rushabh Mehta | 13531b7 | 2012-02-20 12:35:23 +0530 | [diff] [blame] | 27 | except webnotes.UnknownDomainError, e: |
Anand Doshi | b319d2c | 2012-02-17 12:47:36 +0530 | [diff] [blame] | 28 | print "Location: " + (webnotes.defs.redirect_404) |
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() |