PWeb Controller

A Controller in the MVC (Model-View-Controller) architecture is the component that serves as an intermediary between the Model and the View. Its primary role is to handle user input, process it, and determine how to update both the Model and the View.

from pweb import Blueprint
from pweb_form_rest import ssr_ui_render

url_prefix = "/"
home_controller = Blueprint(
    "home_controller",
    __name__,
    url_prefix=url_prefix
)


@home_controller.route("/", methods=['GET'])
def index():
    return ssr_ui_render(view_name="home/index")

Here

  • url_prefix : Prefix of the URL

  • home_controller : Definition of the controller

  • index() : Action of the controller

  • @home_controller.route("/", methods=['GET']) : Routing of a controller

  • ssr_ui_render(view_name="home/index") : Locate the view file

  • methods=['GET'] : HTTP Method of a action.

    • GET

    • POST

    • DELETE