I'm using Flask 0.8.
How to have an alias of a URL like this:
@app.route('/')
def index():
# I want to display as http://localhost/index, BUT, I DON'T WANT TO REDIRECT.
# KEEP URL with only '/'
@app.route('/index')
def index():
# Real processing to display /index view
So, why my hope to use an alias because of DRY of processing /index
Someone knew the solution?
thanks pepperists.
Create a Web alias on your domainClick DNS settings on the Advanced settings tile. Go to DNS records. Under create new record, click Web alias.
The url_for() function is used to build a URL to the specific function dynamically. The first argument is the name of the specified function, and then we can pass any number of keyword argument corresponding to the variable part of the URL.
URL aliases (e.g., “about-us” instead of “node/9”) are automatically assigned by default, and are what appear in the URL of your individual pages (e.g., http://YOURSITE.berkeley.edu/about-us).
This should work. But why do you want two URL's to display the same thing?
@app.route('/')
@app.route('/index')
def index():
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With