Split Python Flask app into multiple files

后端 未结 4 1274
执念已碎
执念已碎 2020-11-27 10:28

I\'m having trouble understanding how to split a flask app into multiple files.

I\'m creating a web service and I want to split the api\'s into different files (Acco

4条回答
  •  鱼传尺愫
    2020-11-27 10:51

    If you are using blueprints and want to route / redirect to a url of your blueprint inside a template you are using you need to use the correct url_for statement.

    In your case if you would like to open the url account of your blueprint you have to state it like this in your template:

    href="{{ url_for('account_api.account') }}"
    

    and for the main app it would look like this:

    redirect(url_for('account_api.account'))
    

    Otherwise the werkzeug library will throw an error.

提交回复
热议问题