Getting StartedΒΆ

Install Flask-ImpΒΆ

Install in a Virtual environment

pip install flask-imp

To get started right away, you can use the CLI commands to create a new Flask-Imp project.

flask-imp init

Minimal Flask-Imp SetupΒΆ

Run the following command to create a minimal Flask-Imp project.

flask-imp init -n app --minimal

See CLI Commands / flask-imp init for more information.

The minimal structureΒΆ

Folder StructureΒΆ

app/
β”œβ”€β”€ resources/
β”‚   β”œβ”€β”€ static/...
β”‚   β”œβ”€β”€ templates/
β”‚   β”‚   └── index.html
β”‚   └── index.py
└── __init__.py

File: app/__init__.py

from flask import Flask

from flask_imp import Imp
from flask_imp.config import FlaskConfig, ImpConfig

imp = Imp()


def create_app():
    app = Flask(__name__, static_url_path="/")
    FlaskConfig(
        secret_key="secret_key",
        app_instance=app
    )

    imp.init_app(app, ImpConfig())

    imp.import_app_resources()
    # Takes argument 'folder' default folder is 'resources'

    return app

File: app/resources/routes.py

from flask import current_app as app
from flask import render_template


@app.route("/")
def index():
    return render_template("index.html")

File: app/resources/templates/index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Flask-Imp</title>
</head>
<body>
<h1>Flask-Imp</h1>
</body>
</html>

Setup a Virtual EnvironmentΒΆ

Setting up a virtual environment is recommended.

Linux / Darwin

python3 -m venv venv
source venv/bin/activate

Windows

python -m venv venv
.\venv\Scripts\activate