-1

EDIT: I am using ATOM as my code editor

This is my first flask app. This is the code for api.py:

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello, World!'

@app.route('/csi/')
def cs():
    return 'Hello, World!'

app.run()

I am able to display the home page with the route('/'), however, when I run the URL with extension route('/csi'), it displays 404 not found.

This is what I tried to run: http://127.0.0.1:5000/csi

and got the following error message:

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

saucypanda
  • 37
  • 1
  • 8
  • 1
    Try removing the trailing `/` from `/csi/` – rdas Jan 15 '21 at 11:14
  • The code looks fine. I have tried it with python 3.9.1. Both the routes were working for me. – Rahul Sapparapu Jan 15 '21 at 11:23
  • So you are running it in ATOM, in that case ATOM is also your web client (most people will use "browser" instead of "web client" - well, web client is the more general term). – Wolf Jan 15 '21 at 11:40
  • What version of flask are you using? I'm getting [308](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/308) for `http://127.0.0.1:5000/csi` instead of [404](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404) – Wolf Jan 15 '21 at 11:46

1 Answers1

0

you're entering the wrong URL when you code this :

@app.route('/csi/')
def cs():
    return 'Hello, World!'

 app.run()

your url has to be : http://127.0.0.1:5000/csi/

Wolf
  • 9,679
  • 7
  • 62
  • 108