Rushabh Mehta | 66ac2b0 | 2011-09-05 18:43:09 +0530 | [diff] [blame] | 1 | #!/usr/bin/python |
Rushabh Mehta | 3966f1d | 2012-02-23 12:35:32 +0530 | [diff] [blame] | 2 | |
| 3 | # ERPNext - web based ERP (http://erpnext.com) |
| 4 | # Copyright (C) 2012 Web Notes Technologies Pvt Ltd |
| 5 | # |
| 6 | # This program is free software: you can redistribute it and/or modify |
| 7 | # it under the terms of the GNU General Public License as published by |
| 8 | # the Free Software Foundation, either version 3 of the License, or |
| 9 | # (at your option) any later version. |
| 10 | # |
| 11 | # This program is distributed in the hope that it will be useful, |
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | # GNU General Public License for more details. |
| 15 | # |
| 16 | # You should have received a copy of the GNU General Public License |
| 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | |
Rushabh Mehta | 66ac2b0 | 2011-09-05 18:43:09 +0530 | [diff] [blame] | 19 | |
| 20 | import cgi, cgitb, os, sys |
| 21 | cgitb.enable() |
| 22 | |
| 23 | # import libs |
| 24 | sys.path.append('lib/py') |
| 25 | sys.path.append('erpnext') |
| 26 | |
| 27 | import webnotes |
Rushabh Mehta | 9ef63f9 | 2012-02-01 14:47:29 +0530 | [diff] [blame] | 28 | import webnotes.handler |
| 29 | import webnotes.auth |
Anand Doshi | b319d2c | 2012-02-17 12:47:36 +0530 | [diff] [blame] | 30 | import webnotes.defs |
Rushabh Mehta | 66ac2b0 | 2011-09-05 18:43:09 +0530 | [diff] [blame] | 31 | |
Rushabh Mehta | 9ef63f9 | 2012-02-01 14:47:29 +0530 | [diff] [blame] | 32 | def init(): |
| 33 | # make the form_dict |
| 34 | webnotes.form = cgi.FieldStorage(keep_blank_values=True) |
| 35 | for key in webnotes.form.keys(): |
| 36 | webnotes.form_dict[key] = webnotes.form.getvalue(key) |
Rushabh Mehta | 66ac2b0 | 2011-09-05 18:43:09 +0530 | [diff] [blame] | 37 | |
Rushabh Mehta | 9ef63f9 | 2012-02-01 14:47:29 +0530 | [diff] [blame] | 38 | # init request |
Rushabh Mehta | 4167e2f | 2012-02-06 10:58:48 +0100 | [diff] [blame] | 39 | try: |
| 40 | webnotes.http_request = webnotes.auth.HTTPRequest() |
Rushabh Mehta | afaac60 | 2012-02-14 11:44:13 +0530 | [diff] [blame] | 41 | except webnotes.AuthenticationError, e: |
| 42 | pass |
Rushabh Mehta | 13531b7 | 2012-02-20 12:35:23 +0530 | [diff] [blame] | 43 | except webnotes.UnknownDomainError, e: |
Anand Doshi | b319d2c | 2012-02-17 12:47:36 +0530 | [diff] [blame] | 44 | print "Location: " + (webnotes.defs.redirect_404) |
Rushabh Mehta | 66ac2b0 | 2011-09-05 18:43:09 +0530 | [diff] [blame] | 45 | |
Rushabh Mehta | 9ef63f9 | 2012-02-01 14:47:29 +0530 | [diff] [blame] | 46 | def respond(): |
| 47 | import webnotes |
| 48 | if 'cmd' in webnotes.form_dict: |
| 49 | webnotes.handler.handle() |
| 50 | else: |
Rushabh Mehta | 8ebf4e2 | 2012-02-07 13:31:09 +0530 | [diff] [blame] | 51 | import webnotes.cms.index |
Rushabh Mehta | 9ef63f9 | 2012-02-01 14:47:29 +0530 | [diff] [blame] | 52 | print "Content-Type: text/html" |
| 53 | webnotes.handler.print_cookies() |
| 54 | print |
Rushabh Mehta | 8ebf4e2 | 2012-02-07 13:31:09 +0530 | [diff] [blame] | 55 | print webnotes.cms.index.get() |
Rushabh Mehta | 5ede3e8 | 2011-09-08 14:16:34 +0530 | [diff] [blame] | 56 | |
Rushabh Mehta | 9ef63f9 | 2012-02-01 14:47:29 +0530 | [diff] [blame] | 57 | if __name__=="__main__": |
| 58 | init() |
Rushabh Mehta | 4167e2f | 2012-02-06 10:58:48 +0100 | [diff] [blame] | 59 | respond() |