How to snap a simple flask application

Is there a good example or tutorial on how to snap a simple python3 Flask application?

It seems to be a simple task which despite this has me caught in lots of work and perils.

i dont think there is any tutorial, but i happen to recently have started an opencv demo that is embedded in a HTML page and served through flask here:

perhaps that gives you some hints …

So, I’ve finally - after massive issues all over - been able to produce a simple example snap containing a flask application.

The process is as follows:

  1. Produce the charmcraft.yaml
  2. Use the python plugin to install flask - Make it a part.
  3. Use the dump plugin to place the python-file with your flask app - Make it a second part.
  4. Use “organize” to copy the file to a place available to your command, e.g. bin/ or so.
  5. Create the command/service.
name: microsample
version: git
summary: A simple flask microservice on
description: |
  Get service status with: curl http://hostip:8080/  (Will return "Online" if OK)
grade: devel # must be 'stable' to release into candidate/stable channels

confinement: strict # use 'strict' once you have the right plugs and slots

# This helps, for example, to build only on archs we can run on.
  - build-on: amd64

base: core22

    command: bin/flask run -h -p 8080
    daemon: simple
    restart-condition: always
    plugs: [network-bind]
      FLASK_APP: ./
      LC_ALL: C.UTF-8
      LANG: C.UTF-8


# This installs flask using python pip.
    plugin: python
    source: .
    python-packages: [ flask ]
# This dumps our sources including
# where we manually have to copy the
# into place.
    plugin: dump
    source: .
# flask could be installed like this instead in the plugin.
#    stage-packages: [ python3-flask ]
    organize: bin/


Snapping a Flask application refers to packaging it as a Snap, which is a universal Linux package format. Here’s how you can snap a simple Flask application:

  1. Install the Snapcraft tool: Snapcraft is the tool used to package and distribute snaps. You can install it by running the following command in your terminal:

sudo apt install snapcraft

  1. Create a Snapcraft project: Create a directory for your project and run the following command in your terminal to initialize a Snapcraft project:


snapcraft init

  1. Define your application: In the snap/snapcraft.yaml file, define the parts and plugins required to build and package your Flask application. Here’s an example snapcraft.yaml for a Flask application:

yaml name: my-flask-app version: 0.1 summary: A simple Flask application description: | This is a snap for a simple Flask application.

apps: my-flask-app: command: my-flask-app plugs: - network

parts: my-flask-app: source: . plugin: python python-version: 3 requirements: requirements.txt

  1. Create a requirements.txt file: This file lists the dependencies required by your Flask application. Here’s an example for a simple Flask application:


  1. Build the snap: Run the following command in your terminal to build the snap:


  1. Install the snap: Run the following command to install the snap:

sudo snap install my-flask-app_0.1_all.snap

Note: This is a basic example and may not cover all the requirements for your specific Flask application. You may need to consult the Snapcraft documentation or seek help from the Snapcraft community for more complex applications. I’m damn sure it will fix sanp flask aappliccation issue but in case if it does not work you can move samsung handy reparatur berlin for detailed answer.

1 Like

please do not do (or suggest) that.

the apt based snapcraft is deprecated and heavily outdated, the correct command is:

$ sudo snap install snapcraft --classic
1 Like