|
|
|
|
|
by lothiraldan
4036 days ago
|
|
Here is my comment of the article in case it was not accepted: First, there is a limitation of Flask itself, not Python. Flask uses the name of the function to allow you to retrieve the url of a specific endpoint with url_for. So technically lambda would not either but you can trick by defining a local function and changing the name of it or using a class. Here is a working example of what you were trying to do: https://gist.github.com/Lothiraldan/87bf5fc9fba604ececa0. Good news, if you want this genericity, you could use pluggable views from flask http://flask.pocoo.org/docs/0.10/views/. And finally you can dynamically inject something into your global namespace using this format: globals()[page] = endpoint but against it will not works due to internal flask limitation not Python one. So yes, Flask design is simple, maybe too much for your utilization and Python is flawed but just like every god damned language. |
|