Flask vs Bottle Web Framework
Tags: python, flask, bottle
Published: 2019-10-30 09:51:24

---
title: Flask vs Bottle Web Framework
cover_image: https://cdn.pixabay.com/photo/2019/10/23/12/58/cobweb-4571556_960_720.jpg
tags: python, flask, bottle
published: true
---
Both <a href="https://palletsprojects.com/p/flask/">Flask</a> and <a href="https://bottlepy.org/docs/dev/">Bottle</a> are frequently used as the backend web frameworks for Python. Anyhow, Flask is said to be more efficient, and as a consequence, programmers often choose it instead of Bottle. 

Let’s see down below what are the advantages of these frameworks and how they differ in terms of functionality and usage. 
 
Before attempting web programming, learn the <a href="https://pythonbasics.org">basics of Python</a>.

## Advantages of using Flask

Flask’s main advantage is that it has access to a multitude of online resources for documentation purposes. 

It is one of the most used Python web frameworks, which is why there are available a lot of tutorials or libraries for it. 

Also, what recommends Flask as the go-to structure is its minimalist approach that does not lose form its power. It is simple to run with either vanilla HTML or bootstrap functionalities. 

```python
    from flask import Flask, escape, request

    app = Flask(__name__)

    @app.route('/')
    def hello():
        name = request.args.get("name", "World")
        return f'Hello, {escape(name)}!'
```

Also, Flask is excellent for creating quick prototypes due to the useful tools included in its package. You can opt for ORM or exact SQL, while all the information related to it is available in the vast array of documentation. 

Of course, some drawbacks arise from using Flask. First of all, there is no async programming included, while the default setup for designing apps in Flask is quite challenging in terms of reusability and code cleanliness. Besides, a disadvantage of using Flask might be the HTML-oriented structure, which is not meant for creating APIs but still allows the design of APIs.
 
## Advantages of using Bottle

Bottle has as its core advantage of the single-file distribution process. It signifies that it is simple to share or upload the app, as it is basically designed as a single Python file. In addition, Bottle is quite flexible, as it features all the necessary features for a website, such as routing or templating.

```python
    from bottle import route, run, template
    
    @route('/hello/<name>')
    def index(name):
        return template('<b>Hello {{name}}</b>!', name=name)
    
    run(host='localhost', port=8080)
```


Another pro of Bottle is the fact that it is featured in the basic library of Python, meaning you won’t need to install anything else to access it. And it is a WSGI app, making it simple to link with almost anything. 

<img src="https://bottlepy.org/docs/dev/_static/logo_nav.png">

The drawback of using Bottle might be the difficulty of finding documentation or online support. Also, it is quite challenging to establish projects broader than 1000 lines. Bottle is suitable for smaller apps, as it is challenging to manage. And this might be a result of the single-file distribution pattern that lacks some Flask blueprints.
 
Overall, when it comes to choosing between Flask or Bottle, everything is about your project’s particularities. Flask is great for any type of web application, no matter its size. It can adapt to all sorts of functionalities, while it offers excellent support from communities or tutorials. On the other hand, Bottle is best as a framework if you need to create a project fast. Besides, it is quite useful for small scale web dev projects, as it is fast and reliable.

**Related links**
* <a href="https://gum.co/IMzBy">Course: Create Web Apps with Flask</a>
* <a href="https://flask.palletsprojects.com/en/1.1.x/">Flask Framework webpage</a>
* <a href="https://bottlepy.org/docs/dev/">Bottle Web Framework webpage</a>
* <a href="https://pythonbasics.org/flask-tutorial-hello-world/">Flask Hello World tutorial</a>