Skip to main content
BackAnt uses Flask’s Blueprint system to organize routes. Each resource gets its own Blueprint registered at a URL prefix.

How routes are structured

Every route file defines a Blueprint, registers it at a URL prefix, and exposes endpoint functions that call the service layer:
from flask import Blueprint, jsonify
from services.users_service import myUsersService

users_bp = Blueprint("users", __name__, url_prefix="/users")

@users_bp.get("")
def get_users():
    response = myUsersService.get_users()
    return jsonify(response)
The Blueprint is then registered in api/app.py:
from routes.users_route import users_bp
app.register_blueprint(users_bp)
When you run ant generate route users, both the route file and the app.py registration are created and wired automatically.

HTTP methods

Flask Blueprints support all standard HTTP methods as decorators:
@users_bp.get("")          # GET /users
@users_bp.post("/create")  # POST /users/create
@users_bp.put("/update")   # PUT /users/update
@users_bp.delete("/remove") # DELETE /users/remove

Subroutes

A subroute is an additional endpoint appended to an existing Blueprint. When you run ant generate subroute users profile, the following is added to users_route.py:
@users_bp.get("/profile")
def users_profile_route():
    response = myUsersService.get_profile()
    return jsonify(response)
And a corresponding method is added to users_service.py and users_repository.py.

URL structure

Given a route named users with subroutes profile and create:
MethodURLHandler
GET/usersget_users()
GET/users/profileget_profile()
POST/users/createcreate_create(data)

Generating routes and subroutes

ant generate route users
ant generate subroute users profile
ant generate subroute users create --type POST
See the CLI Reference for all options.

Naming rules

Route names must be valid Python identifiers:
✅ users, user_posts, products_v2, api_keys
❌ my-route, user posts, 1users, user.posts
The route name determines the URL prefix, file names, class names, and singleton names — see Architecture for the full naming table.

Accessing request data

Inside a route function, use Flask’s request object:
from flask import request

@users_bp.post("/create")
def create_user():
    data = request.get_json()
    response = myUsersService.create_user(data)
    return jsonify(response)
See Requests for full details.