klen/muffin

Question: how to separate urls from views ?

vlad0337187 opened this issue · 1 comments

Is there a standard way to do it ?

I want to separate urls from views just like Django does.
The only way I see not - creating 'urls.py' with list of lists: ['url', 'function_name']

After this importing that urls, importing all functions from views and check name correspondence, if corresponds - simulate @app.register('url_from_urls_py', function_instance).

But, maybe, there is some standard way ?

Offtop: maybe there are some ready Muffin applications for me to see usage examples ? If yes - give me a link please.

Offtop 2: if you have vk.com or Telegram account (or, maybe, there is some vk.com group for muffin), and you're not against me to ask you questions there sometimes (as rarely as possible), than give me please contacts.

Thank you.
Best regards,
Vladislav.

klen commented

better late than never

# your_project.__init__.py
import muffin

app = muffin.Application()

from .urls import * # noqa

# your_project.urls.py
from your project import app
from your_project.views import index, profile, login, logout

app.route('/', index)
app.route('/profile', profile)
app.route('/login', login)
app.route('/logout', logout)