html generation moved from web.py to web_cache.py so it can be called from other places as a response from server.py
diff --git a/erpnext/website/utils.py b/erpnext/website/utils.py
index 22fcce7..470dbd7 100644
--- a/erpnext/website/utils.py
+++ b/erpnext/website/utils.py
@@ -41,3 +41,37 @@
 	name = title.lower()
 	name = re.sub('[~!@#$%^&*()<>,."\']', '', name)
 	return '-'.join(name.split()[:4])
+
+def render(page_name):
+	"""render html page"""
+	import webnotes
+	try:
+		if page_name:
+			html = get_html(page_name)
+		else:
+			html = get_html('index')
+	except Exception, e:
+		html = get_html('404')
+
+	print "Content-Type: text/html"
+	print
+	print html.encode('utf-8')
+	
+def get_html(page_name):
+	"""get page html"""
+	page_name = scrub_page_name(page_name)
+	comments = get_comments(page_name)
+	
+	import website.web_cache
+	html = website.web_cache.get_html(page_name, comments)
+	return html
+
+def get_comments(page_name):
+	import webnotes
+	
+	if page_name == '404':
+		comments = """error: %s""" % webnotes.getTraceback()
+	else:
+		comments = """page: %s""" % page_name
+		
+	return comments	
diff --git a/erpnext/website/web_cache.py b/erpnext/website/web_cache.py
index 893f7f2..e08499b 100644
--- a/erpnext/website/web_cache.py
+++ b/erpnext/website/web_cache.py
@@ -91,6 +91,7 @@
 	return page_list
 
 def prepare_args(page_name):
+	import webnotes
 	if page_name == 'index':
 		page_name = get_home_page()
 
@@ -98,6 +99,7 @@
 		args = {
 			'template': 'pages/%s.html' % page_name,
 			'name': page_name,
+			'webnotes': webnotes
 		}
 	else:
 		args = get_doc_fields(page_name)