title: How to replace spaces in URL having path parameter, with a hyphen or an underscore
body: <p>I am sorry if this Q makes no sense , but is there a way to replace spaces with hyphen in URL's(only) having used path parameter to build it ?</p>
  
  <p>My scenario is as :</p>
  
  <p>I have a view method as below:</p>
  
  <pre><code>from app.service import *
  
  @app.route('/myapp/&lt;search_url&gt;',methods=['GET','POST'])
  def search_func(search_url):
      print(search_url) // This prints 'hi-martin king' and i need to pass 'hi-martin king' to below with preserving space
      search_q = search(search_url) 
      return render_template('wordsearch.html',data=search_q['data'])
  </code></pre>
  
  <ul>
  <li>here <code>search_url</code> I am passing from template</li>
  </ul>
  
  <p>I have the <code>search</code> function which takes <code>search_url</code> as argument(<code>def search(search_url): .....</code>) and does all operations (for ref) which i have imported from service above. </p>
  
  <p>Now when I run , i have the sample URL as,</p>
  
  <pre><code>....myapp/hi-martin%20king
  </code></pre>
  
  <p>Here I am preserving space to perform query in database (In db it is stored as <code>martin king</code>), but I don't want to show the same in URL instead replace it with a hyphen </p>
  
  <p>I have other way that changing all the values in database (removing spaces but this is tmk not a appropriate solution)</p>
  
  <h2>expected o/p:</h2>
  
  <pre><code>....myapp/hi-martin-king  (or with an underscore) ....myapp/hi-martin_king 
  </code></pre>
  
  <p>Here how can i preserve spaces to pass it as argument to the function and at the same time I want to replace only in URL ? Is this possible ?</p>
  
  <p>Any help is appreciated ....TIA</p>