Jump to content

Problem with flask links


heirloom

Recommended Posts

I have an app with static paths like this:

import sys
import platform

from flask import Flask, __version__
app = Flask(__name__)

@app.route("/")
def hello():
    return """
        Hello World!<br><br>
        <a href="/info/">System Information</a>
    """

@app.route("/info/")
def info():
    return f"""
        Platform: {platform.platform()}<br>
        Python version {sys.version}<br>
        Flask version: {__version__}
    """

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

But when I use it in heliohost the links have to be prefixed with '/flask/'. Is there a way to do this without having to change all the links in the application?

Edited by heirloom
Link to comment
Share on other sites

Are you asking about how to run flask in your web root instead of a subdirectory? You just move all your files from public_html/flask/ to public_html/ and then update your .htaccess and flask.wsgi paths to match. The reason we recommend running flask in a subdirectory is so you can use your account for more than one thing. If you run flask in the web root, then that's all you can do with your whole account.

Link to comment
Share on other sites

Nice, it's good to know that I can run flask from the web root. That's not what I'm asking though. I want to keep flask in the subdirectory. But the routes of my app don't take into account that subdirectory so I need a way to append '/flask/' to all routes without actually having to change them one by one in the code.

Edited by heirloom
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...