Skip to content
This repository was archived by the owner on Dec 4, 2022. It is now read-only.

Latest commit

 

History

33 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Radish

Radish

Radish is a simple router implementation for my web framework, Ermine. However, it can also be used for other things, and provides complete typing. It does use an regex tree for routing.

🔑 Key Features

  • simple
  • elegant
  • comprehensiv

Quick example

⬇️ Installation


pip install radish-router

🤔 Inspiration

Radish is inspired by:

🌟 Features:

  • simple matching
  • dynamic routes
  • parameters
  • wildcards
  • regex

🔭 Examples

Basic static route matching

from radish import Radish

router = Radish()

handler = lambda: "Hello World!"

router.insert("get", "/hello/world", handler)

print(router.get("get", "/hello/world"))
# will return  
# {"route": "/user","handler": handler, "params": {}}

Route parameters

from radish import Radish

route =  Radish()

handler = lambda: "Hello World!"

router.insert("get", "/hello/:name", handler)

router.insert("get", "/user/:uid|uuid", handler)

router.insert("get", "/static/*filename", handler)

print(router.get("get", "/user/16e55f79-baa7-46ed-b9a8-8dabc35c6381"))

print(router.get("get", "/hello/world"))

About

a simple router in Python

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Contributors

Languages