0

I thought I'd finished pset8 and was about to start on my final project when I realised that 'articles' was defaulting to onion news all the time, even when I used the test address. It's a while since I finished the code as I've been busy over easter so I don't remember for sure if I checked before whether the articles were coming from google or onion. I cannot work out where I'm going wrong - everything else works but this - and surely if it was the issue where google blocks you for trying too many calls on one api then it would have reset by now - I haven't used it for weeks! I assume it's how I'm passing postcode to articles but I can't see anything wrong with the code. I'd really appreciate some help so I can move on!! Here's my articles code (and yes, postcode is set as 'text' in the database!):

@app.route("/articles")
def articles():
"""Look up articles for geo."""
if request.method == "GET":

    geo = str(request.args.get("q"))      
    result = lookup(geo)
    return jsonify(result)

Thank you!

0

The spec says articles should "geo is passed into/articlesas a GET parameter,". q is specified in the query string for /search. Maybe a typo here geo = str(request.args.get("q"))? What results do you get with a straight call to .../articles?geo=02138 example from the spec? What parameter(s) are you sending to articles in addMarker?

2
  • Thank you again DCS!! I realised I'd put 'q' in instead of 'geo' - as in "geo is passed..." doh!!! Now ...articles?geo=02138 test is showing the google list of articles (yay!) but my markers are still showing onion ones - and when I tested my search with the ...search?q=02138 test it came back blank (it was working b4)...I tested what 'q' is returning and it's blank - so my search must be wrong - arrgggg!!! Or maybe it's 'showInfo'... TBH I'm so tired I can hardly see straight so I'll check it all tomorrow and if it's still not working I'll post another question - but thank you again!!! :-)
    – CallyB
    Apr 27 '17 at 22:02
  • Yayy! I think it's working!!!! I was just checking a more obscure postcode that had got onion articles attached, but when I searched for big cities and then clicked on them, I got the local news - I guess there are a lot of smaller places that get onion news results...at least I hope that's it!!! Thanks DCS - now I can start my final project!!!!!
    – CallyB
    Apr 28 '17 at 9:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .