#๐Ÿ”’ when I run this code and try to access my program I get a 404 error

7 messages ยท Page 1 of 1 (latest)

clever kettle
#

So I installed Postman like it said and now I copied the example code line for line. It should find the file but when I browse to the API I'm building with it gives me a 404 error:

#let's import the flask

from flask import Flask, Response
import json
import os

app = Flask(__name__)

@app.route('/apu/v1.0/students', methods = ['GET'])
def students():
    student_list = [
        {
           'name':'Asabeneh',
        'country':'Finland',
        'city':'Helsinki',
        'skills':['HTML','CSS','JavaScript','Python']
 
        },
        {
            'name':'David',
            'country':'UK',
            'city':'London',
            'skills':['Python', 'MongoDB']
        },
        {
            'name':'John',
            'country':'Sweden',
            'city':'Stockholm',
            'skills':['Java','C#']
        }
    ]
    return Response(json.dumps(student_list), mimetype='application/json')

if __name__ == '__main__':
    # for deployment
    #to make it work for both production and development
    port = int(os.environ.get("PORT", 5000))
    app.run(debug=True, host='0.0.0.0', port=port)

This is for the last challenge of this course:

https://github.com/Asabeneh/30-Days-Of-Python/blob/master/29_Day_Building_API/29_building_API.md

The file is saved as Day 29.py I always run the program before trying to access it in my browser and it appears to run just fine but browser can't find the program. I don't think the issue is with the code itself as much as the browser being able to see the code.

GitHub

30 days of Python programming challenge is a step-by-step guide to learn the Python programming language in 30 days. This challenge may take more than100 days, follow your own pace. These videos m...

untold meadowBOT
#

@clever kettle

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

clever kettle
#

hi just posting here to keep thread open

#

I will try making a new thread later

#

!close

untold meadowBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.