I have at the moment to figure out where "favicon.ico" comes from. It is really super weird.
I use geopy to geocode a location into latitude and longitude, then I use these values to create markers on a google map (Flask GoogleMaps).
That is the piece of code:
try:
print findroomcity
location = geolocator.geocode(findroomcity)
print location, location.latitude, location.longitude
if location:
mymap = Map(
identifier="view-side",
lat=location.latitude,
lng=location.longitude,
markers=[(location.latitude, location.longitude)],
zoom = 12
)
else:
print "location is none"
In this case findroomcity
is "dortmund". It is actually grabbed from a form.
If I submit the form the map is actually created, so it does not use the else block
But it tells me that location in NoneType and has no attribute latitude. It seems that it calls the try block three times and the first time findroomcity
is "favicon.ico", also the last time
Check the outputs of the prints:
I dont even used "favicon.ico" in my whole project, I know it must be somewhere but I checked every .py file and also searched for every print
. I am really super confused, I keep searching, but maybe someone has encountered something similar.
Here is the whole method which creates the map:
# Die Filter Funktion mit Google Maps
@app.route('/<findroomcity>', methods=["GET", "POST"])
def find_room(findroomcity):
form = FilterZimmerForm()
if form.validate_on_submit():
query = Zimmer.query
filter_list = ["haustiere_erlaubt","bettwaesche_wird_gestellt","grill_vorhanden","safe_vorhanden","kuehlschrank_vorhanden","rauchen_erlaubt","parkplatz_vorhanden",
"kochmoeglichkeit_vorhanden","restaurant_im_haus_vorhanden","handtuecher_werden_gestellt","tv_vorhanden","waschmoeglichkeit_vorhanden","wlan_vorhanden"]
for filter_name in filter_list:
if getattr(form, filter_name).data:
query = query.filter(getattr(Zimmer, filter_name).is_(True))
all_rooms_in_city = query.all()
else:
all_rooms_in_city = Zimmer.query.order_by(desc("stadt")).all()
try:
print findroomcity
location = geolocator.geocode(findroomcity)
print location, location.latitude, location.longitude
if location:
mymap = Map(
identifier="view-side",
lat=location.latitude,
lng=location.longitude,
markers=[(location.latitude, location.longitude)],
zoom = 12
)
else:
print "location is none"
except AttributeError as e:
flash("Ort nicht gefunden")
print e
return redirect(url_for('index'))
except GeocoderTimedOut as e:
print e
sleep(1)
return render_template('zimmer_gefunden.html', mymap=mymap, all_rooms_in_city=all_rooms_in_city, findroomcity=findroomcity, form=form)
EDIT
I have really no idea where it comes from, I use now:
if location.latitude is not None: