java_geek
java_geek

Reputation: 18035

Sample Bottle App (Python) gives 404 even though route is defined

I am just getting started with Bottle. I have found a sample app on GitHub. The sample just has a server.py file which looks like below

import bottle

APP = bottle.Bottle()

@APP.get('/')
def index():
  return '<p>Hello</p>'

if __name__ == '__main__':
  bottle.run(application=APP)

The requirements.txt file has

bottle
gunicorn

as dependencies. I am using Python 3.7.2. After running pip install -r requirements.txt, I ran python server.py. The server starts up without error on Port 8080

Bottle v0.12.18 server starting up (using WSGIRefServer(application=<bottle.Bottle object at 0x1040fa2d0>))...
Listening on http://127.0.0.1:8080/

When I access http://localhost:8080, I get

Error: 404 Not Found
Sorry, the requested URL 'http://localhost:8080/' caused an error:

Not found: '/'

Please let me know what's wrong with the setup.

Upvotes: 1

Views: 456

Answers (1)

badreelal patidar
badreelal patidar

Reputation: 256

Just replace bottle.run(application=APP) application arg name to app bottle.run(app=APP)

Upvotes: 2

Related Questions