Add a prefix to all Flask routes

后端 未结 10 944
你的背包
你的背包 2020-11-22 09:40

I have a prefix that I want to add to every route. Right now I add a constant to the route at every definition. Is there a way to do this automatically?

PR         


        
10条回答
  •  天涯浪人
    2020-11-22 10:35

    I needed similar so called "context-root". I did it in conf file under /etc/httpd/conf.d/ using WSGIScriptAlias :

    myapp.conf:

    
        WSGIScriptAlias /myapp /home//myapp/wsgi.py
    
        /myapp>
            Order deny,allow
            Allow from all
        
    
    
    

    So now I can access my app as : http://localhost:5000/myapp

    See the guide - http://modwsgi.readthedocs.io/en/develop/user-guides/quick-configuration-guide.html

提交回复
热议问题