blob: e7a1d576617d105b921944102b6667718ff3c3ae [file] [log] [blame]
Rushabh Mehta66ac2b02011-09-05 18:43:09 +05301#!/usr/bin/python
Rushabh Mehta3966f1d2012-02-23 12:35:32 +05302
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 Mehta66ac2b02011-09-05 18:43:09 +053019
20import cgi, cgitb, os, sys
21cgitb.enable()
22
23# import libs
24sys.path.append('lib/py')
25sys.path.append('erpnext')
26
27import webnotes
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053028import webnotes.handler
29import webnotes.auth
Anand Doshib319d2c2012-02-17 12:47:36 +053030import webnotes.defs
Rushabh Mehta66ac2b02011-09-05 18:43:09 +053031
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053032def 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 Mehta66ac2b02011-09-05 18:43:09 +053037
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053038 # init request
Rushabh Mehta4167e2f2012-02-06 10:58:48 +010039 try:
40 webnotes.http_request = webnotes.auth.HTTPRequest()
Rushabh Mehtaafaac602012-02-14 11:44:13 +053041 except webnotes.AuthenticationError, e:
42 pass
Rushabh Mehta13531b72012-02-20 12:35:23 +053043 except webnotes.UnknownDomainError, e:
Anand Doshib319d2c2012-02-17 12:47:36 +053044 print "Location: " + (webnotes.defs.redirect_404)
Rushabh Mehta66ac2b02011-09-05 18:43:09 +053045
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053046def respond():
47 import webnotes
48 if 'cmd' in webnotes.form_dict:
49 webnotes.handler.handle()
50 else:
Rushabh Mehta8ebf4e22012-02-07 13:31:09 +053051 import webnotes.cms.index
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053052 print "Content-Type: text/html"
53 webnotes.handler.print_cookies()
54 print
Rushabh Mehta8ebf4e22012-02-07 13:31:09 +053055 print webnotes.cms.index.get()
Rushabh Mehta5ede3e82011-09-08 14:16:34 +053056
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053057if __name__=="__main__":
58 init()
Rushabh Mehta4167e2f2012-02-06 10:58:48 +010059 respond()