Exemple #1
0
def raise404(path=None):
	"""
	Return a Not Found page to the user, with optional path info.
	"""
	content = tags.h1()['Not Found']
	content += tags.hr()
	content += tags.p()['There is no object registered at that path.']
	if(path):
		content += tags.strong()[path]
	content += tags.hr()
	#content += get_process_info()
	raise web.HTTPStatus('404 Not Found', [('Content-Type', 'text/html')], [content])
Exemple #2
0
def raise500(message=None):
	"""
	Sorry, an error has occurred.
	"""
	content = tags.h1()['Internal Server Error']
	content += tags.hr()
	content += tags.p()['Sorry, an error has occurred:']
	if(message):
		content += tags.strong()[message]
	raise web.HTTPStatus('500 Internal Server Error', [('Content-Type', 'text/html')], content)
Exemple #3
0
def raise400(path=None):
	"""
	Bad Request
	"""
	content = tags.h1()['Bad Request']
	content += tags.hr()
	content += tags.p()['Your browser sent an invalid request.']
	if(path):
		content += tags.strong()[path]
	raise web.HTTPStatus('400 Bad Request', [('Content-Type', 'text/html')], [content])
Exemple #4
0
def raise403(path=None):
	"""
	You are not allowed to access that path.
	"""
	content = tags.h1()['Forbidden']
	content += tags.hr()
	content += tags.p()['You are not allowed to access that path.']
	if(path):
		content += tags.strong()[path]
	raise web.HTTPStatus('403 Forbidden', [('Content-Type', 'text/html')], [content])
Exemple #5
0
def raise401(message=None):
	"""
	You have not supplied the appropriate credentials.
	
	Will cause the client browser to display HTTP username/password dialog.
	"""
	if(message is None):
		message = 'You have not supplied the appropriate credentials.'
	
	content = tags.h1()['Unauthorized']
	content += tags.hr()
	content += tags.p()[message]
	raise web.HTTPStatus('401 Unauthorized', [('Content-Type', 'text/html')], [content])