Build the future of communications.
Start building for free

First Steps with Python and Bottle

First Steps with Python & Bottle

Do you want to build your first web application with Python? Or have you been working with a full-featured web framework such as Django or Pyramid and want to try out a microframework? Take four minutes to watch this video and check off “get started using the Bottle web framework” from your 2016 to-do list:

The Code

You can snag the code in the video via this GitHub Gist or just copy from here into a file named app.py:

import bottle
from bottle import route, run, Response


app = bottle.default_app()


@route("/")
def index():
    """Returns standard text response to show app is working."""
    return Response("My Bottle app is up and running!")


if __name__ == '__main__':
    run(host="127.0.0.1", port=5000, debug=False, reloader=True)

Make sure to pip install bottle from PyPI and then run the following command:

python app.py

That’s it, 15 lines of code to respond to incoming HTTP requests with a simple response!

More Resources

With your quick introduction to Bottle out of the way, here’s where to go next to keep learning:

Questions? Contact me via

Authors
Sign up and start building
Not ready yet? Talk to an expert.