def home():
    if 'email' not in session:
        return redirect(url_for('login'))
    form = AddressForm()
    my_coordinates = []
    places = (37.4221, -122.0844)
    if request.method == 'POST':
        if form.validate() == False:
            return render_template('home', form=form)
        else:

            # Get The Address
            address = form.address.data
            # Query the places Around it
            p = Place()
            my_coordinates = p.address_to_latlng(address)
            places = p.query(address)
            # Show the Results
            return render_template('home.html',
                                   form=form,
                                   my_coordinates=my_coordinates,
                                   places=places)

    return render_template('home.html',
                           form=form,
                           my_coordinates=my_coordinates,
                           places=places)
Exemple #2
0
def home():
    if 'email' not in session:
        return redirect(url_for('login'))

    form = AddressForm()

    places = []
    my_coordinates = (18.3893976, -65.99671619999998)  #My Home Location

    if request.method == 'POST':
        if form.validate == False:
            return render_template("home.html", form=form)
        else:

            #Get the Address
            address = form.address.data

            # Query for places around it
            p = Place()
            my_coordinates = p.address_to_latlng(
                address)  #my_coordinates=(18.3893976,-65.99671619999998)
            places = p.query(address)

            # Return the results
            return render_template("home.html",
                                   form=form,
                                   my_coordinates=my_coordinates,
                                   places=places)

    elif request.method == 'GET':
        return render_template("home.html",
                               form=form,
                               my_coordinates=my_coordinates,
                               places=places)
Exemple #3
0
def home():
    if 'account_name' not in session:
        return redirect(url_for('signin'))

    form = AddressForm()

    places = []
    my_coordinates = (30.0000, 30.0000)

    if request.method == 'POST':
        if form.validate == False:
            return render_template("home.html", form=form)
        else:
            # get the address
            address = form.address.data
            # query for places around it
            p = Place()
            my_coordinates = p.address_to_latlng(address)
            places = p.query(address)
            # return those results
            return render_template("home.html",
                                   form=form,
                                   my_coordinates=my_coordinates,
                                   places=places)
    elif request.method == 'GET':
        return render_template("home.html",
                               form=form,
                               my_coordinates=my_coordinates,
                               places=places)

    return render_template("home.html",
                           form=form,
                           my_coordinates=my_coordinates,
                           places=places)
Exemple #4
0
def home():
    form = AddressForm()

    places = []
    my_coordinates = (37.4221, -122.0844)

    if 'email' not in session:
        return redirect(url_for('login'))

    if request.method == 'POST':
        if form.validate() == False:
            return render_template('home.html', form=form)
        else:
            #get the address
            address = form.address.data

            #want to use geodata api - make a model (models.py)
            #query places around address
            p = Place()
            my_coordinates = p.address_to_latlng(address)
            places = p.query(address)

            return render_template('home.html',
                                   form=form,
                                   my_coordinates=my_coordinates,
                                   places=places)

    elif request.method == 'GET':
        return render_template("home.html",
                               form=form,
                               my_coordinates=my_coordinates,
                               places=places)
Exemple #5
0
def home():
    if 'email' not in session:
        return redirect(url_for('login'))

    form = AddressForm()
    places = []
    my_coordinates = (37.4221, -122.0844)

    if request.method == 'POST':
        if form.validate() == False:
            return render_template('home.html', form=form)
        else:
            # get the address
            address = form.address.data
            #address = add

            # query for places around it
            p = Place()
            my_coordinates = p.address_to_latlng(address)
            places = p.query(address)

            # return those results
            return render_template('home.html',
                                   form=form,
                                   my_coordinates=my_coordinates,
                                   places=places)

    elif request.method == 'GET':
        return render_template("home.html",
                               form=form,
                               my_coordinates=my_coordinates,
                               places=places)
Exemple #6
0
def home():
    if 'email' not in session:
        return redirect(url_for('login'))

    form = AddressForm()

    places = []
    my_coordinates = (42.650435, -73.758516)

    if request.method == 'POST' and form.validate():
        # get the address
        address = form.address.data

        # query for places around it
        p = Place()
        my_coordinates = p.address_to_latlng(address)
        places = p.query(address)

        # return the results
        return render_template('home.html', form=form,
                                            my_coordinates=my_coordinates,
                                            places=places)
    return render_template('home.html', form=form,
                                        my_coordinates=my_coordinates,
                                        places=places)
Exemple #7
0
def home():
	if 'email' not in session:
		return redirect(url_for('login'))

	form = AddressForm()

	places = []
	my_coordinates = (37.4221, -122.0844)

	if request.method == 'POST':
		if not form.validate():
			return render_template('home.html', form=form)

		# Handle the Form here.
		# Get the adress.
		address = form.address.data

		# Query for places around it.
		p = Place()
		my_coordinates = p.address_to_latlng(address)
		places = p.query(address)

		# Return those results.
		return render_template('home.html', form=form, my_coordinates=my_coordinates, places=places)
	elif request.method == 'GET':
		return render_template('home.html', form=form, my_coordinates=my_coordinates, places=places)
Exemple #8
0
def home():
    if 'email' not in session:
        return redirect(url_for('login'))
    form = AddressForm()

    places = []
    my_coordinates = (37.4221, -122.0844)  #just dflts, mean nothing
    if request.method == "POST":
        if form.validate == False:
            return render_template('home.html', form=form)
        else:
            # get the addy
            address = form.address.data
            # make a model to wrap or consume the wiki api then query it at https://www.mediawiki.org/wiki/Extension:GeoData#Api
            p = Place()
            my_coordinates = p.address_to_latlng(address)
            places = p.query(address)
            # return results
            return render_template('home.html',
                                   form=form,
                                   my_coordinates=my_coordinates,
                                   places=places)
    elif request.method == "GET":
        return render_template('home.html',
                               form=form,
                               my_coordinates=my_coordinates,
                               places=places)
def home():
    if 'email' not in session:
        return redirect(url_for('login'))

    form = AddressForm()
    my_coordinates = (18.5745, 73.6847)
    places = []

    if request.method == 'GET':
        return render_template("home.html",
                               form=form,
                               my_coordinates=my_coordinates,
                               places=places)

    elif request.method == 'POST':
        if not form.validate:
            return render_template('home.html',
                                   form=form,
                                   my_coordinates=my_coordinates,
                                   places=places)
        else:
            location = form.address.data

            p = Place()
            my_coordinates = p.address_to_latlng(location)
            places = p.query(location)

            return render_template("home.html",
                                   form=form,
                                   my_coordinates=my_coordinates,
                                   places=places)
Exemple #10
0
def home():
	if 'email' not in session:
		return redirect(url_for('login'))
	
	form = AddressForm()
	places = []
	my_coordinates = (37.4221, -122.0844)
	
	if request.method == "POST":
		if form.validate() == False:
			return render_template("home.html", form=form)
		else:
			# get the address
			address = form.address.data

			# query for addresses nearby
			p = Place()

			my_coordinates = p.address_to_latlng(address)
			places = p.query(address)


			# return those results
			return render_template('home.html', form=form, my_coordinates=my_coordinates, places=places)
			

	elif request.method == "GET":
		return render_template("home.html", form=form, my_coordinates=my_coordinates, places=places)
Exemple #11
0
def home():
	if 'email' not in session:
		return redirect(url_for('login'))

	form = AddressForm()

	places = []
	my_coordinates = (50.45146, 30.52187) #37.4221     -122.0844

	if request.method == 'POST':
		if form.validate() == False:
			return render_template("home.html", form=form)
		else:
			address = form.address.data

			p = Place()
			my_coordinates =p.address_to_latlng(address)
			places = p.query(address)

			return render_template("home.html", 
									form=form,
									my_coordinates=my_coordinates,
									places=places)

	elif request.method == 'GET':
		return render_template("home.html", 
								form=form,
								my_coordinates=my_coordinates,
								places=places)

	return render_template("home.html")
def home():
    #protects the home page, turn off to turn on home
    if 'email' not in session:
        return redirect(url_for('login'))
    
    form = AddressForm()
    
    places = []
    my_coordinates = (0.0000,0.0000) #null island
    
    if request.method =="POST":
        if form.validate == False:
            return render_template("home.html", form = form)
        else:
            #handle form submission
            #pass
            address = form.address.data
            p = Place()
            my_coordinates = p.address_to_latlng(address)
            places = p.query(address)
            
            return render_template('home.html',form=form, my_coordinates, places=places)
    
    elif request.method == "GET":
        return render_template('home.html',form=form, my_coordinates, places=places)
Exemple #13
0
def home():
    if "email" not in session:
        return redirect(url_for("login"))

    form = AddressForm()

    places = []
    my_coordinates = (40.7308619, -73.9871558)

    if request.method == "POST":
        if form.validate() == False:
            return render_template("home.html", form=form)
        else:
            # get the address
            address = form.address.data

            # query for places around it
            my_point = Place()
            my_coordinates = my_point.address_to_latlng(address)
            places = my_point.query(address)

            # return those results
            return render_template("home.html",
                                   form=form,
                                   my_coordinates=my_coordinates,
                                   places=places)

    elif request.method == "GET":
        return render_template("home.html",
                               form=form,
                               my_coordinates=my_coordinates,
                               places=places)
Exemple #14
0
def home():
    if 'email' not in session:
        return redirect(url_for('login'))

    form = AddressForm()

    places = []
    my_coordinates = (45.975589, 15.060825)

    if request.method == 'POST':
        if not form.validate():
            return render_template('home.html', form=form)
        else:
            # get the address
            address = form.address.data
            # query for places around it
            p = Place()
            my_coordinates = p.address_to_latlng(address)
            places = p.query(address)
            # return those results
            return render_template('home.html', form=form, my_coordinates=my_coordinates, places=places)

    elif request.method == 'GET':
        return render_template('home.html', form=form, my_coordinates=my_coordinates, places=places)

    return render_template('home.html')
Exemple #15
0
def home():
    #enable this to have user login and permission
    # if 'email' not in session:
    #    return redirect(url_for('login'))

    form = AddressForm()

    places = []
    my_coordinates = (43.6629, -79.3957)

    if request.method == 'POST':
        if form.validate() == False:
            return render_template('home.html', form=form)
        else:
            # get the address
            address = form.address.data

            # query for places around it
            p = Place()
            my_coordinates = p.address_to_latlng(address)
            places = p.query(address)

            # return those results
            return render_template('home.html',
                                   form=form,
                                   my_coordinates=my_coordinates,
                                   places=places)

    elif request.method == 'GET':
        return render_template("home.html",
                               form=form,
                               my_coordinates=my_coordinates,
                               places=places)
Exemple #16
0
def home():
    if 'email' not in session:  #checks to see if logged in or not
        return redirect(url_for('login'))

    form = AddressForm()

    places = []
    my_coordinates = (41.7508, 88.1535)

    if request.method == 'POST':
        if form.validate() == False:
            my_coordinates = (41.7508, 88.1535)
            return render_template('home.html',
                                   form=form,
                                   my_coordinates=my_coordinates)
        else:
            # get the address
            address = form.address.data
            # query for places around it
            p = Place()
            my_coordinates = p.address_to_latlng(address)
            places = p.query(address)

            # return those results
            return render_template('home.html',
                                   form=form,
                                   my_coordinates=my_coordinates,
                                   places=places)

    elif request.method == 'GET':
        return render_template("home.html",
                               form=form,
                               my_coordinates=my_coordinates,
                               places=places)
def home():

    form = AddressForm()

    places = []
    my_coordinates = (34.023076, -118.2870456)

    if request.method == 'POST':
        if form.validate() == False:
            return render_template('home.html', form=form)
        else:
            # get the address
            address = form.address.data

            # query for places around it
            p = Place()
            my_coordinates = p.address_to_latlng(address)
            places = p.query(address)

            # return those results
            return render_template('home.html',
                                   form=form,
                                   my_coordinates=my_coordinates,
                                   places=places)

    elif request.method == 'GET':
        return render_template("home.html",
                               form=form,
                               my_coordinates=my_coordinates,
                               places=places)
Exemple #18
0
def home():
    if 'email' not in session:
        return redirect(url_for('login'))

    form = AddressForm()

    places = []
    my_coordinates = (66, -99)

    if request.method == 'POST':
        if form.validate() == False:
            return render_template('home.html',
                                   form=form,
                                   my_coordinates=my_coordinates,
                                   places=places)
        else:
            address = form.address.data
            print(address)

            p = Place()
            my_coordinates = p.address_to_latlng(address)
            places = p.get_places(*my_coordinates)

            return render_template('home.html',
                                   form=form,
                                   my_coordinates=my_coordinates,
                                   places=places)
    elif request.method == 'GET':
        return render_template('home.html',
                               form=form,
                               my_coordinates=my_coordinates,
                               places=places)
Exemple #19
0
def home():
    if 'email' not in session:
        return redirect(url_for('login'))

    form = AddressForm()
    places = []
    my_coordinates = (37.4221, -122.0844)

    if request.method == 'POST':
        if form.validate() == False:
            return render_template("home.html",
                                   form=form,
                                   my_coordinates=my_coordinates,
                                   places=places)
        else:
            address = form.address.data
            p = Place()
            my_coordinates = p.address_to_latlng(address)
            places = p.query(address)
            return render_template("home.html",
                                   form=form,
                                   my_coordinates=my_coordinates,
                                   places=places)

    if request.method == 'GET':
        return render_template("home.html",
                               form=form,
                               my_coordinates=my_coordinates,
                               places=places)

    return render_template("home.html")
Exemple #20
0
def home():
  if 'email' not in session:
    return redirect(url_for('login'))

  form = AddressForm()

  places = []
  my_coordinates = (5.3109351,-1.9924259)

  if request.method == 'POST':
    if form.validate() == False:
      return render_template('home.html', form=form)
    else:
      # get the address
      address = form.address.data

      # query for places around it
      p = Place()
      my_coordinates = p.address_to_latlng(address)
      places = p.query(address)

      # return those results
      return render_template('home.html', form=form, my_coordinates=my_coordinates, places=places)

  elif request.method == 'GET':
    return render_template("home.html", form=form, my_coordinates=my_coordinates, places=places)
def home():
    if "email" not in session:
        return redirect(url_for("login"))

    form = AddressForm()
    places = []
    my_coordinates = [37.4221, -122.0844]

    if request.method == "POST":
        if not form.validate():
            return render_template("home.html", form=form)
        else:
            # get address
            address = form.address.data
            # query for places
            p = Place()
            my_coordinates = p.address_to_latlng(address)
            places = p.query(address)
            # return results
            return render_template("home.html",
                                   form=form,
                                   my_coordinates=my_coordinates,
                                   places=places)
    elif request.method == "GET":
        return render_template("home.html",
                               form=form,
                               my_coordinates=my_coordinates,
                               places=places)
def home():
    if 'email' not in session:
        return redirect(url_for('login'))

    form = AddressForm()
    places = []
    my_coordinates = (37.4221, -122.0844)

    if request.method == "POST":
        if form.validate() == False:
            return render_template("home.html", form=form)
        else:
            #handle good case
            # Get the address
            address = form.address.data

            # Search for places around it
            p = Place()
            my_coordinates = p.address_to_latlng(address)
            places = p.query(address)

            # Return the results
            return render_template("home.html",
                                   form=form,
                                   my_coordinates=my_coordinates,
                                   places=places)

    elif request.method == "GET":
        return render_template("home.html",
                               form=form,
                               my_coordinates=my_coordinates,
                               places=places)
Exemple #23
0
def nearby(tid):
    """Nearby uses flask_wtform and wikipedia apis.

    Get the address, query for places around it
    (currently wikipedia, may become locations of tickets),
    return results.
    """
    tid = tid
    ticket = Ticket.query.get(tid)
    pickup_address = ticket.pickup_address
    pickup_ll = geocoder.google(pickup_address)
    p_lat, p_lng = pickup_ll.lat, pickup_ll.lng
    form = AddressForm()
    places = []
    my_coordinates = (p_lat, p_lng)
    lat_lng = (p_lat, p_lng)

    if request.method == 'POST':
        if form.validate() is False:
            return render_template('nearby.html', form=form, tid=tid,
                                   ticket=ticket)
        else:
            address = form.address.data
            p = Place()
            my_coordinates = p.address_to_latlng(address)
            places = p.main(address)

            return render_template('nearby.html', form=form, places=places,
                                   my_coordinates=my_coordinates, tid=tid,
                                   lat_lng=lat_lng, ticket=ticket)

    elif request.method == 'GET':
        return render_template("nearby.html", form=form, places=places,
                               my_coordinates=my_coordinates, tid=tid,
                               lat_lng=lat_lng, ticket=ticket)
Exemple #24
0
def home():
    if 'email' not in session:
        return redirect(url_for('login'))

    form = AddressForm()

    places = []
    my_coordinates = (33.7489, -84.3789)  # Based on the city of Atlanta

    if request.method == 'POST':
        if form.validate() == False:
            return render_template('home.html', form=form)
        else:
            # get the address
            address = form.address.data

            # query for places around it
            p = Place()
            my_coordinates = p.address_to_latlng(address)
            places = p.query(address)

            # return those results
            return render_template('home.html',
                                   form=form,
                                   my_coordinates=my_coordinates,
                                   places=places)

    elif request.method == 'GET':
        return render_template('home.html',
                               form=form,
                               my_coordinates=my_coordinates,
                               places=places)
Exemple #25
0
def home():
    if 'email' not in session:
        return redirect(url_for('login'))

    form = AddressForm()

    places = []
    my_coordinates = (40.7127750, -74.0059730)

    if request.method == 'POST':
        if form.validate() == False:
            return render_template('home.html', form=form)
        else:
            #get address
            address = form.address.data

            #search places around it
            p = Place()
            my_coordinates = p.address_to_latlng(address)
            places = p.query(address)

            #return results

            return render_template('home.html',
                                   form=form,
                                   my_coordinates=my_coordinates,
                                   places=places)

    elif request.method == 'GET':
        return render_template('home.html',
                               form=form,
                               my_coordinates=my_coordinates,
                               places=places)
Exemple #26
0
def home():
    form = AddressForm()
    places, lat_lon = [], (12.836649, 77.655809)
    if request.method == 'POST':
        if not form.validate():
            return render_template('home.html', form=form)
        else:
            address = form.address.data
            p = Place()
            fetched_lat_lon = p.address_to_latlng(address)

            if any(lat_lon):
                places = p.query(address)
                return render_template('home.html',
                                       form=form,
                                       my_coordinates=fetched_lat_lon,
                                       places=places)
            else:
                return render_template('home.html', form=form)

    elif request.method == 'GET':
        return render_template('home.html',
                               form=form,
                               my_coordinates=lat_lon,
                               places=places)
Exemple #27
0
def home():
	if 'email' not in session:
		return redirect(url_for("login"))

	form=AddressForm()

	places = []
	my_coordinates = (30.620949, -96.350764)

	if request.method=="POST":
		if form.validate() == False:
			return render_template("home.html", form=form)
		else:
			# get the address
			address=form.address.data
			print("Hello")

			# query for places around it
			p=Place()
			my_coordinates = p.address_to_latlng(address)
			print(my_coordinates)
			places=p.query(address)

			# return those results
			return render_template("home.html", form=form, my_coordinates=my_coordinates, places=places)

	elif request.method=="GET":
		return render_template("home.html", form=form, my_coordinates=my_coordinates, places=places)
def home():
    form = AddressForm()
    p = Place()

    if request.method == 'GET':
        places = []
        gl = session.get('_location', None)
        gl = get_user_location() if gl is None else Geolocation(*gl)
        if gl is None:
            form.address.data = 'London, UK'
        else:
            form.address.data = '{}, {}, {} {}'.format(gl.city, gl.region_name,
                                                       gl.country_name,
                                                       gl.zip_code)

        my_coordinates = p.address_to_latlng(form.address.data)
        if not all(my_coordinates):
            # failed to decode address to lat, lng
            form.address.errors += (
                'Invalid address',
            )  # form.address.errors is a immutable tuple
        else:
            places = p.query(form.address.data)

        return render_template('home.html',
                               form=form,
                               my_coordinates=my_coordinates,
                               places=places)

    elif request.method == 'POST':
        if form.validate() == False:
            return render_template('home.html', form=form)
        else:
            # get the address
            address = form.address.data

            # query for places around the address
            my_coordinates = p.address_to_latlng(address)
            places = p.query(address)

            # return the results as a list
            return render_template('home.html',
                                   form=form,
                                   my_coordinates=my_coordinates,
                                   places=places)
Exemple #29
0
def home():
    # if the user is not logged in, send them to log in. this "protects" the home page
    if "email" not in session:
        return redirect(url_for("login"))

    # in this function, form refers to an instance of address form that we imported from our forms.py
    form = AddressForm()
    # so we can access these two things later.
    places = []

    #default coordinates to start with on the map
    #first_load = 1
    my_coordinates = (39.281496, -76.6119114)
    # if the url is POSTing something
    if request.method == "POST":
        # if the form doesn' validate, try again
        if form.validate() == False:
            return render_template("home.html",
                                   form=form,
                                   session=session,
                                   first_load=1)
        else:
            # if the form validates, get address from form
            address = form.address.data
            # query nearby locations
            # p is an instance of the Place class that we import from the models
            p = Place()
            # coordinates reset to
            my_coordinates = p.address_to_latlng(address)
            places = p.query(address)

            # if (my_coordinates == (39.281496, -76.6119114)):
            #     first_load = 0
            #return results
            return render_template("home.html",
                                   form=form,
                                   my_coordinates=my_coordinates,
                                   places=places,
                                   session=session,
                                   first_load=0)

    elif request.method == "GET":
        return render_template("home.html",
                               form=form,
                               my_coordinates=my_coordinates,
                               places=places,
                               session=session,
                               first_load=1)
Exemple #30
0
def home():
	if 'email' not in session:
		return redirect(url_for('login'))
	form = AddressForm()
	places = []
	my_coords = geocoder.google('Mountain View, CA').latlng
	if request.method == 'POST':
		if not form.validate():
			return render_template('home.html', form=form, my_coords=my_coords)
		else:
			address = form.address.data
			p = Place()
			my_coords = p.address_to_latlng(address)
			places = p.query(address)
			return render_template('home.html', form=form, my_coords=my_coords, places=places)
	elif request.method == 'GET':
		return render_template('home.html', form=form, my_coords=my_coords,places=places)
Exemple #31
0
def home():
	if 'email' not in session:
		return redirect(url_for('login'))
	form = SearchForm()
	places = []
	my_coordinates = (37.4221, -122.0844)
	if request.method == "POST":
		if form.validate == False:
			return render_template("home.html", form=form)
		else:
			address = form.address.data
			p = Place()
			my_coordinates = p.address_to_latlng(address)
			places = p.query(address)
			return render_template('home.html', form=form, my_coordinates=my_coordinates, places=places)
	elif request.method == "GET":
		return render_template('home.html', form=form, my_coordinates=my_coordinates, places=places)
Exemple #32
0
def map():
    this_route = url_for('.map')
    if 'email' not in session:
        app.logger.info(
            "Can't access {} without session id".format(this_route))
        return redirect(url_for('login'))

    form = AddressForm()

    places = []
    ip = urllib.request.urlopen('https://ident.me').read().decode('utf8')
    g = geocoder.ip(ip)
    my_coordinates = (g.lat, g.lng)

    if request.method == 'POST':
        if form.validate() == False:
            app.logger.info("Map request invalid {}".format(this_route))
            return render_template('map.html', form=form)
        else:
            # get the address
            address = form.address.data
            # query for places around it
            p = Place()
            my_coordinates = p.address_to_latlng(address)
            places = p.query(address)
            app.logger.info("Map request success {}".format(this_route))
            # return those results
            return render_template('map.html',
                                   form=form,
                                   my_coordinates=my_coordinates,
                                   places=places)

    elif request.method == 'GET':
        app.logger.info("GET {}".format(this_route))
        return render_template("map.html",
                               form=form,
                               my_coordinates=my_coordinates,
                               places=places)

    app.logger.info("Logging a test message from {}".format(this_route))
    return render_template("map.html")
Exemple #33
0
def home():
    if 'email' not in session:
        return redirect(url_for('login'))
    
    form=AddressForm()
    places = []
    my_coordinates = (12.3444,-142.3814)

    if request.method == "POST":
        if form.validate() == False:
            return render_template("home.html", form=form)
        else:
            # get the address
            address = form.Address.data
            # query for nearby places
            p=Place()
            my_coordinates = p.address_to_latlng(address)
            places = p.query(address)

            # return those results
            return render_template("home.html", form=form, my_coordinates=my_coordinates, places=places)
    else:        
        return render_template("home.html", form=form, my_coordinates=my_coordinates, places=places)
Exemple #34
0
def home():
    """ Renders the home page """

    if 'email' not in session:
        return redirect(url_for('login'))

    form = AddressForm()

    places = []
    my_coordinates = (-1.2886111111111, 36.823055555556)

    if request.method == 'POST':
        if form.validate():
            # get the address
            address = form.address.data

            # query for places around it
            p = Place()
            my_coordinates = p.address_to_latlng(address)
            places = p.query(address)

            # return results
            return render_template("home.html",
                                   form=form,
                                   my_coordinates=my_coordinates,
                                   places=places,
                                   logout=True)

        else:
            return render_template("home.html", form=form, logout=True)

    elif request.method == 'GET':
        return render_template("home.html",
                               form=form,
                               my_coordinates=my_coordinates,
                               places=places,
                               logout=True)
Exemple #35
0
def home():
    # Check if email has been set in session - if not, user is not
    # logged in and should be redirected to log in page
    if "email" not in session:
        return redirect(url_for("login"))

    form = AddressForm()
    places = []
    coordinates = (37.4221, -122.0844)

    if request.method == "POST":
        if form.validate() == False:
            return render_template("home.html",
                                   form=form,
                                   coordinates=coordinates,
                                   places=places)
        else:
            # Get the address from the form
            address = form.address.data

            # Query for places around it
            p = Place()
            coordinates = p.address_to_latlng(address)
            places = p.query(address)

            # Return results
            return render_template("home.html",
                                   form=form,
                                   coordinates=coordinates,
                                   places=places)

    elif request.method == "GET":
        return render_template("home.html",
                               form=form,
                               coordinates=coordinates,
                               places=places)