I have one question regarding the search part of mashup. It is almost working as intended, but when I try to search by postal code it works for the first digits (for example: 554), but when I type the next number 5542, the suggestion only shows ” , ,” even if it should match the postal codes starting with 5542 in the database.
I have checked that the url "https://ide50-username.cs50.io/search?q=554 returns the correct JSON data.
Postal code is of type TEXT in my database for simplicity in the search part.
It may seem like it is having problems displaying less than 10 suggestions? Anyone know what is wrong?
Here is my search function:
@app.route("/search") def search(): """Search for places that match query.""" q = request.args.get("q") + "%" result = db.execute("SELECT * FROM places WHERE postal_code LIKE :q OR place_name LIKE :q OR admin_name1 LIKE :q", q=q) if len(result)>10: return jsonify([result, result, result, result, result, result, result, result, result, result]) else: return jsonify([result])