Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@app.register(muffin.HTTPNotFound)
def handle_404(request):
return muffin.Response(text='Custom 404', status=404)
@app.register(muffin.HTTPNotFound)
def handle404(request):
""" Handle HTTP exceptions. """
return muffin.Response(text='Custom 404 Page', status=404)
def raise404(request):
""" Raise HTTP exceptions. """
raise muffin.HTTPNotFound
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()
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()