Skip to content
site logo mobile

Forum in maintenance, we will back soon 🙂

404 error - Build g...
 
Notifications
Clear all

404 error - Build google api

5 Posts
3 Users
0 Reactions
46 Views
(@tayo-ojulari)
Posts: 2
New Member Customer Registered
Power Member
Pythonista Prodigy Badge
Topic starter
 

Hi

 

I was just trying to follow along with the video to build the google keyword search API but return page not found error? Has something changed or am i doing something wrong?

 

Serving Flask app 'app'
* Debug mode: on
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI serv
er instead.
* Running on http://127.0.0.1:5000
Press CTRL+C to quit
* Restarting with stat
* Debugger is active!
* Debugger PIN: 668-945-949
127.0.0.1 - - [28/Apr/2024 07:17:45] "GET / HTTP/1.1" 404 -
127.0.0.1 - - [28/Apr/2024 07:17:53] "GET /shoes HTTP/1.1" 404 -
127.0.0.1 - - [28/Apr/2024 07:18:37] "GET /shoes HTTP/1.1" 404 -
127.0.0.1 - - [28/Apr/2024 07:18:37] "GET /favicon.ico HTTP/1.1" 404 -
127.0.0.1 - - [28/Apr/2024 07:18:53] "GET /build%20apis HTTP/1.1" 404 -

 

ot Found

The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

 

Thank you

 

Tayo

 
Posted : 04/28/2024 6:24 am
Hasan Aboul Hasan
(@admin)
Posts: 1098
Member Admin
Premium Member
Pythonista Prodigy Badge
Prompt Engineer
API Entrepreneur
Power Member
 

can you please share the code ? is it my code? 

 
Posted : 04/28/2024 10:07 am
SSAdvisor
(@ssadvisor)
Posts: 1059
Noble Member
Premium Member
Pythonista Prodigy Badge
Prompt Engineer
API Entrepreneur
Power Member
 

@tayo-ojulari what routes did you define? The routes determine what should follow the 5000; for example http://127.0.0.1:5000/myroute. You can define a route for '/' which is typically called the index page so you avoid the not found error.

Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack

 
Posted : 04/28/2024 12:40 pm
(@tayo-ojulari)
Posts: 2
New Member Customer Registered
Power Member
Pythonista Prodigy Badge
Topic starter
 

@admin yes i used your code, see below:

 

from flask import Flask, request, jsonify
import requests

app = Flask(__name__)

GOOGLE_SUGGEST_API_URL = "http://suggestqueries.google.com/complete/search"
@app.route('/keywords', methods=['GET'])
def get_keywords():
    query = request.args.get('query')
    if not query:
        return jsonify({'error': 'Query parameter is missing.'}), 400

    params = {
        'client': 'firefox',
        'q': query,
        'hl': 'en'  # Language code for English
    }

    try:
        response = requests.get(GOOGLE_SUGGEST_API_URL, params=params)
        response.raise_for_status()
        suggestions = response.json()[1]
        return jsonify({'suggestions': suggestions})
    except requests.RequestException as e:
        return jsonify({'error': str(e)}), 500
if __name__ == '__main__':
    app.run(debug=True)
 
Posted : 04/28/2024 1:13 pm
SSAdvisor
(@ssadvisor)
Posts: 1059
Noble Member
Premium Member
Pythonista Prodigy Badge
Prompt Engineer
API Entrepreneur
Power Member
 

@tayo-ojulari so your route is /keywords with a query of "query". The URL you need is http://127.0.0.1:5000/keywords?query ="Whatever You Want To Search"

Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack

 
Posted : 04/28/2024 1:56 pm
Share: