def register_process(): """Process registration for passengers and drivers.""" # Get form variables from register_form email = request.form.get("email") password = request.form.get("password") firstname = request.form.get("firstname") lastname = request.form.get("lastname") phonenumber = request.form.get("phonenumber") # we don't want to have 2 people checking in under same address print request.form['user_type'] #adding new passenger and driver to the db if request.form["user_type"] == 'passenger': # give me passenger with this email passenger = Passenger.query.filter_by(email=email).first() if passenger: flash("You have already registered as a passenger. Please log in.") return redirect('/login') new_passenger = Passenger(email=email, password=password, firstname=firstname, lastname=lastname, phonenumber=phonenumber) db.session.add(new_passenger) #committing the new driver and passenger to the db db.session.commit() #alert-message that will give name and email of passenger sign in flash("Passenger %s added." % email) # set passenger_id session["passenger_id"] = new_passenger.passenger_id return redirect("/feed") else: driver = Driver.query.filter_by(email=email).first() if driver: flash("You have already registered as a passenger. Please log in.") return redirect('/login') new_driver = Driver(email=email, password=password, firstname=firstname, lastname=lastname, phonenumber=phonenumber) db.session.add(new_driver) #committing the new driver and passenger to the db db.session.commit() #alert-message that will give name and email of driver sign in flash("Driver %s added." % email) #set driver_id session["driver_id"] = new_driver.driver_id #driver.driver_id return redirect("/feed")
def handle(event, context): body = json.loads(event.get('body')) email = body.get('email') password = body.get('password') result = Driver.authenticate(email, password) response = { 'statusCode': 200, 'body': json.dumps(result) } return response
def handle(event, context): body = json.loads(event.get('body')) id = body.get('id') driver = Driver(id=id) db = Database() db.delete(driver) response = { 'statusCode': 200, 'body': json.dumps({'msg': f'Driver with id {id} deleted successfully'}), } return response
def add_drivers(): """Seed fake drivers to database.""" for row in open("static/driver.csv"): row = row.strip() zipcode, driver_fname, driver_lname, driver_gender, company, green_star = row.split(",") driver = Driver(zipcode=zipcode, driver_fname=driver_fname, driver_lname=driver_lname, driver_gender=driver_gender, company=company, green_star=green_star) db.session.add(driver) db.session.commit() print "Done seeding drivers"
def handle(event, context): body = json.loads(event.get('body')) driver = Driver(**body) db = Database() db.add(driver) driver.__dict__.pop('_sa_instance_state') response = { 'statusCode': 200, 'body': json.dumps({ 'driver': driver.__dict__, 'msg': f'Driver {driver.id} added successfully' }), } return response
lastname='Granger', email='*****@*****.**', password='******') # We need to add to the session or it won't ever be stored db.session.add(passenger) # Once we're done, we should commit our work db.session.commit() ################################################################################# #Drivers driver = Driver(firstname=NULL, lastname='Snape', driver_location='Forbidden Forest', email='*****@*****.**', password='******') # We need to add to the session or it won't ever be stored db.session.add(driver) driver = Driver(firstname='Professor', lastname='Dumbledore', driver_location='Kings Cross Station, Platform 9.75', email='*****@*****.**', password='******') # We need to add to the session or it won't ever be stored db.session.add(driver)
from model import Driver, ModelType from data import TrainingData """The training of the CNN is performed in two steps. The first step runs with a limited training set for 5 epochs with a learning rate of 0.001. This has been found to establish a solid foundation that allows the car to make it all the way around the track, albeit in a rather slopy way. The second step trains with a lower learning rate and much more data for an additional 5 epochs. This fills in the gaps in the CNN and smooths out the driving considerably. """ # build the driver driver = Driver((80, 80, 1)) driver.build(ModelType.CONV1) ##################### Initial training #################### initial_data = [ './data/trk1_normal_1', './data/trk1_normal_2', './data/trk1_normal_3', './data/trk1_corner_infill', './data/udacity_data', ] # 1) The initial training step data = TrainingData(initial_data) driver.trainGen(data.training_generator, data.training_size, 5, data.validation_generator, data.validation_size, lr=0.001)