Is it possible to mark a method with a route in Flask?
<p>It's possible to subclass <code>Flask</code>:</p>

<pre><code>from flask import Flask

class MyServer(Flask):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

    def my_cool_method(self):
        print("About to do some crazy productive work!")
</code></pre>

<p>By doing this, one could create a <code>MyServer</code> object and define a route which, when hit, calls a method.</p>

<pre><code>my_server = MyServer(__name__)

@my_server.route("/my_cool_endpoint")
def my_cool_endpoint():
    my_server.my_cool_method()
</code></pre>

<p>Is there any possible way to cut out this seemingly unnecessary (and fairly unsustainable) step and simply decorate a <em>method</em> with a route?</p>

<p>My pseudocode would be something like...</p>

<pre><code>#!/usr/bin/env python3

from flask import Flask

class MyServer(Flask):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

    @self.route("/my_cool_endpoint")
    def my_cool_method(self):
        print("About to do some crazy productive work!")

if __name__ == "__main__":
    my_server = MyServer(__name__)
    # We can now hit 127.0.0.1:8080/my_cool_endpoint... hopefully
    my_server.run(port=8080)
</code></pre>

<p>My motivation is to simply <code>run</code> the object and let the endpoints get hit, modifying the state of the object on each API call.</p>

<p>If this isn't possible exactly as I've described, what's the least offensive way to accomplish my goal?</p>