DEV Community

Samandar Ravshanov
Samandar Ravshanov

Posted on • Edited on

📦Generate string from URL pattern

from functorflow import ff

# Generate string from URL pattern and values:


pattern = ff("make-url-pattern", pattern="/api/products(/:id)")
res = pattern.stringify( vals={ "id": 43 } ) 

print(res) # '/api/products/43'



# Match pattern against string and extract values:

pattern = ff("make-url-pattern", pattern="/api/products(/:id)")
res = pattern.match( url="/api/products/5" ) 

print(res) # {'id': '5'}
Enter fullscreen mode Exit fullscreen mode

Stop wasting time installing and configuring Python libraries. Use them right away. 📦FunctorFlow instantly auto-install and auto-config them for you.

Top comments (0)