Beispiel #1
0
def generate_ticket():
	response = {}
	try:
		vehicle_type = request.form['vehicle_type']
		toll_type = request.form['toll_type']
		timestamp = request.form['time']
		price = request.form['price']
		vehicle_no = request.form['vehicle_no']
	except KeyError as e:
		print e
		response['success'] = False
		response['data'] = []
		response['message'] = 'Required Parameters not sent'
		return_obj = jsonify(response)
		return_obj.status_code = 400
		return return_obj
	try:	
		formObject = Formvalidation()
		print vehicle_type,toll_type,timestamp,price,vehicle_no
		status = formObject.validate_data(vehicle_type,toll_type,timestamp,price,vehicle_no)
		if status == 'Success':
			response['success'] = True
			response['data'] = []
			response['message'] = 'Great Success'
			return_obj = jsonify(response)
			return return_obj
	except Exception as e:
			print e
			response['success'] = False 
			response['data'] = []
			response['message'] = str(e)
			return_obj = jsonify(response)
			return_obj.status_code = 500
			return return_obj
from Formvalidation import Formvalidation

obj = Formvalidation()
# try:
# 	obj.validate_data('','','','')

# except Exception as e:
# 	print e

try:
	obj.validate_data('1','1','2014-07-17','55.0','KA01-HV7382')
except Exception as e:
	print e