blob: 686ce057fcc2c29d5a5d44f3d8d65bd06e68817e [file] [log] [blame]
Rushabh Mehta66ac2b02011-09-05 18:43:09 +05301#!/usr/bin/python
2# main handler file
3
4import cgi, cgitb, os, sys
5cgitb.enable()
6
7# import libs
8sys.path.append('lib/py')
9sys.path.append('erpnext')
10
11import webnotes
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053012import webnotes.handler
13import webnotes.auth
Anand Doshib319d2c2012-02-17 12:47:36 +053014import webnotes.defs
Rushabh Mehta66ac2b02011-09-05 18:43:09 +053015
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053016def 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 Mehta66ac2b02011-09-05 18:43:09 +053021
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053022 # init request
Rushabh Mehta4167e2f2012-02-06 10:58:48 +010023 try:
24 webnotes.http_request = webnotes.auth.HTTPRequest()
Rushabh Mehtaafaac602012-02-14 11:44:13 +053025 except webnotes.AuthenticationError, e:
26 pass
Rushabh Mehta13531b72012-02-20 12:35:23 +053027 except webnotes.UnknownDomainError, e:
Anand Doshib319d2c2012-02-17 12:47:36 +053028 print "Location: " + (webnotes.defs.redirect_404)
Rushabh Mehta66ac2b02011-09-05 18:43:09 +053029
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053030def respond():
31 import webnotes
32 if 'cmd' in webnotes.form_dict:
33 webnotes.handler.handle()
34 else:
Rushabh Mehta8ebf4e22012-02-07 13:31:09 +053035 import webnotes.cms.index
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053036 print "Content-Type: text/html"
37 webnotes.handler.print_cookies()
38 print
Rushabh Mehta8ebf4e22012-02-07 13:31:09 +053039 print webnotes.cms.index.get()
Rushabh Mehta5ede3e82011-09-08 14:16:34 +053040
Rushabh Mehta9ef63f92012-02-01 14:47:29 +053041if __name__=="__main__":
42 init()
Rushabh Mehta4167e2f2012-02-06 10:58:48 +010043 respond()