Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8888845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:07:13+00:00 2026-06-14T22:07:13+00:00

Possible Duplicate: Using mappings in CherryPy How would I map a url regEx such

  • 0

Possible Duplicate:
Using mappings in CherryPy

How would I map a url regEx such as /data/[A-Z].txt to a resource in cherrypy? Is there an simple example somewhere? I don’t get the docs here.

http://tools.cherrypy.org/wiki/RestfulDispatch

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:07:14+00:00Added an answer on June 14, 2026 at 10:07 pm

    You could use a RoutesDispatcher

    import cherrypy
    
    class City:
        def __init__(self, name):
            self.name = name
            self.population = 10000
    
        @cherrypy.expose
        def index(self, **kwargs):
            return "Welcome to %s, pop. %s" % (self.name, self.population)
    
        @cherrypy.expose
        def update(self, **kwargs):
            self.population = kwargs['pop']
            return "OK"
    
    d = cherrypy.dispatch.RoutesDispatcher()
    d.connect(action='index', name='hounslow', route='/hounslow', controller=City('Hounslow'))
    d.connect(action='index', name='surbiton', route='/surbiton', controller=City('Surbiton'),
              conditions=dict(method=['GET']))
    d.mapper.connect('/surbiton', controller='surbiton',
                     action='update', conditions=dict(method=['POST']))
    
    conf = {'/': {'request.dispatch': d}}
    cherrypy.config.update({'server.socket_port': 5000})
    cherrypy.tree.mount(root=None, config=conf)
    cherrypy.engine.start()
    

    You might test this with a browser on http://127.0.0.1:5000/surbiton
    You can test the POST command with curl:

    curl -i -X GET http://127.0.0.1:5000/surbiton
    curl -i -d "pop=100" -X POST http://127.0.0.1:5000/surbiton
    curl -i -X GET http://127.0.0.1:5000/surbiton
    

    There is the documentaton from the Routes project.

    Or this example from appmecha.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: using mysql_close() Are mysql_close and pg_close required ? In some script there
Possible Duplicate: Using String Format to show decimal upto 2 places or simple integer
Possible Duplicate: using razor within javascript I would like to place a siimple value
Possible Duplicate: Using jQuery, Restricting File Size Before Uploading Is there a good jquery
Possible Duplicate: Using LGPL library in a commercial Java application Hello guys! There is
Possible Duplicate: Using java to create a web browser Is there any way to
Possible Duplicate: Using an ORM or plain SQL? Would you elect to use an
Possible Duplicate: Using Git with an existing Xcode project Setting up a git repository
Possible Duplicate: Using ASP.NET Controls without databinding My previous question yielded few results so
Possible Duplicate: using bash: write bit representation of integer to file I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.