Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

276
Views
Use regular expressions to extract information from a URL

How to get page id by URL in Flask?

http://localhost/page34
http://localhost/page35

I want the word "page" to be fixed with a letter or number next to it representing the page, how do I do this?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Adapted from this answer. You can also use this example from the documentation of Werkzeug.

from flask import Flask
from werkzeug.routing import BaseConverter

class RegexConverter(BaseConverter):
    def __init__(self, url_map, *items):
        super().__init__(url_map)
        self.regex = items[0]

app = Flask(__name__)
app.url_map.converters['regex'] = RegexConverter

@app.route('/page<regex("\d+"):page_id>/')
def page(page_id):
    return f"Page ID: {page_id}"

if __name__ == '__main__':
    app.run()

enter image description here

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!