How to use the muffin.HTTPNotFound function in muffin

To help you get started, we’ve selected a few muffin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github klen / muffin / tests / test_muffin.py View on Github external
    @app.register(muffin.HTTPNotFound)
    def handle_404(request):
        return muffin.Response(text='Custom 404', status=404)
github klen / muffin / example / views.py View on Github external
@app.register(muffin.HTTPNotFound)
def handle404(request):
    """ Handle HTTP exceptions. """
    return muffin.Response(text='Custom 404 Page', status=404)
github klen / muffin / example / views.py View on Github external
def raise404(request):
    """ Raise HTTP exceptions. """
    raise muffin.HTTPNotFound
github klen / muffin-admin / muffin_admin / peewee.py View on Github external
def load_one(self, request):
        """Load a resource."""
        resource = request.query.get('pk')
        if not resource:
            return None

        try:
            return self.collection.where(self.model._meta.primary_key == resource).get()
        except Exception:
            raise muffin.HTTPNotFound()
github klen / muffin-admin / muffin_admin / peewee.py View on Github external
def delete(self, request):
        """Delete an item."""
        if not self.can_delete:
            raise muffin.HTTPMethodNotAllowed()

        if not self.resource:
            raise muffin.HTTPNotFound(reason='Resource not found')

        self.resource.delete_instance()