Merly
  • Quick start
  • Guide
    • Routing
    • Start
    • Headers
    • CORS
    • Http methods available
    • Statics files
    • Custom 404 Handler
    • Body parser
    • Middleware
  • Website
  • Code
  • Examples
Powered by GitBook
On this page

Was this helpful?

  1. Guide

Custom 404 Handler

It is possible to return a personalized message when a route cannot be found.

notfound

The notfound method allows you to customize the response of the 404 error code, it is possible to pass the html code in string format to the method.

notfound("""<!DOCTYPE html>
              <html>
              <head><title>Not found</title></head>
              <body><h1>404, Not found</h1></body>
              </html>""")

It is also possible to pass a path that includes the name of the html file to use. The path will start from the directory where the program is located or from the path specified as a base.

notfound("folder/notfound.html")

PreviousStatics filesNextBody parser

Last updated 4 years ago

Was this helpful?