Skip to content

Controller Based Routing #194

@ZeroIntensity

Description

@ZeroIntensity

Proposal:

To fit with other frameworks, view.py should implement controllers (i.e. routing based on classes). This should be pretty easy, actually. This won't be a new loader strategy, but will act sort of like a router. For example:

from view import new_app, get

app = new_app()

class MyController(Controller):
    @get("/")
    def get(self):
        return "Hello, world!"

# Alternatively, we can implicitly call the router function
class MyOtherController(Controller):
    def get(self, test: str):  # Automatic input
        return "Hello, world!"

app.load(MyController(), MyOtherController())
app.run()

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiThis has to do with the Python API (view)featureNew feature

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions