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

  • SEARCH
  • Home
  • 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 9155051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:31:38+00:00 2026-06-17T12:31:38+00:00

Here is a portion of my python code: @app.route(/<int:param>/) def go_to(param): return param The

  • 0

Here is a portion of my python code:

@app.route("/<int:param>/")
def go_to(param):
    return param

The above function routes a url such as www.example.com/12 to this function.

How can I declare a parameter rule to redirect urls ending with integers, such as www.example.com/and/boy/12, to this function?

I’m using the Flask framework.

  • 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-17T12:31:38+00:00Added an answer on June 17, 2026 at 12:31 pm

    You will need Werkzeug routing.

    Complete code:

    from flask import Flask
    from werkzeug.routing import BaseConverter
    
    app = Flask(__name__)
    
    class RegexConverter(BaseConverter):
            def __init__(self, url_map, *items):
                    super(RegexConverter, self).__init__(url_map)
                    self.regex = items[0]
    
    app.url_map.converters['regex'] = RegexConverter
    
    # To get all URLs ending with "/number"
    @app.route("/<regex('.*\/([0-9]+)'):param>/")
    def go_to_one(param):
        return param.split("/")[-1]
    
    # To get all URLs ending with a number
    @app.route("/<regex('.*([0-9]+)'):param>/")
    def go_to_one(param):
        return param.split("/")[-1]
    
    # To get all URLs without a number
    @app.route("/<regex('[^0-9]+'):param>/")
    def go_to_two(param):
        return param
    
    @app.route('/')
    def hello_world():
        return 'Hello World!'
    
    if __name__ == '__main__':
        app.run()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is a portion of my app.yaml file: handlers: - url: /remote_api script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py
Here is a portion of my code: var styles:String = .keyword{color: #ff0000;} .comment{color: #00ff00;};
Here is the code in a function I'm trying to revise. This example works
Here's a portion of the html code I'm trying to submit the textarea, much
Alright, so here's the portion of my code that is giving me a problem.
here is a portion of code I'm using to enable/disable a button (which allows
here is the portion of code giving me trouble: IF EXIST TH_BUILD_* ( ECHO
I want to convert this particular portion of code in C++ to python But
Here is a portion of my struts.xml: <constant name=struts.custom.i18n.resources value=global /> and <action name=picture_save
I'm trying to extract a portion of html between 2 comments. here is the

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.