First protected app / Step 1 of 6

Prepare your environment

Source and package versions

One AIWAF repository. Python: py/aiwaf/ · Node.js: js/ · Rust/WASM: rust/ · Java: java/. Source and canonical README. Versions shown describe the source checkout; package releases are independent. Current Python/Node source targets are aiwaf 1.1.8 (Python) and aiwaf 1.1.5 (npm), with Rust/Python 0.2.7 and WASM 0.2.5 and Java 1.3.5. Sandbox guides retain their separately pinned builds.

This tutorial builds a small Flask API and follows one request from the client through AIWAF to the handler and request log. You will see three successful requests followed by a rate-limit response, and then exempt one route without removing protection from the others.

Before you begin

Use Python 3.11 or newer, a terminal, and an empty directory. The commands use the current Python AIWAF API. They do not require Redis, a trained model, or the AIWAF source checkout. Python 1.1.4 installs the required Rust runtime. Flask is the teaching example; use the framework guides if you are integrating an existing app.

1. Create a workspace

mkdir aiwaf-demo
cd aiwaf-demo
python -m venv .venv

A virtual environment keeps the tutorial's packages separate from other applications. Run every later command from this directory with that environment active.

2. Activate the environment

Linux and macOS

source .venv/bin/activate

Windows PowerShell

.\.venv\Scripts\Activate.ps1

If your machine names Python python3 or uses the py launcher, use that command to create the environment. Once active, python should refer to its interpreter.

3. Install the framework extra

python -m pip install "aiwaf[flask]"
python -m pip show aiwaf Flask

The flask extra installs the dependencies for the Flask adapter. Python 1.1.4 also installs aiwaf-rust>=0.2.3. This walkthrough uses the legacy Flask adapter; the complete native pipeline is configured with NativeAIWAF.

4. Check the import

python -c "from aiwaf.flask import AIWAF; print('Flask adapter ready')"
Flask adapter ready

If the import fails, compare python -m pip --version with the active interpreter. Do not install packages into a different environment to silence the error.

Checkpoint You have an isolated environment and can import the Flask adapter. No server or model is running yet.