首页 > 解决方案 > 为什么烧瓶自动调试在 ubuntu 中不起作用

问题描述

当我跑

python app.py

其中的内容app.py是:

 from flask import Flask ,render_template

    from data import articles


    app=Flask(__name__)

    Articles=articles()

    @app.route('/')
    def index():
        return render_template('home.html')


    @app.route('/about')
    def about():
        return render_template('about.html')

    @app.route('/articles')
    def articles():
        return render_template('articles.html',articles=Articles)


    @app.route('/article/<string:id>/')
    def article(id):
        return render_template('article.html',id=id)

    if __name__=='__main__':
    app.run(debug=True)

我收到以下错误:

Traceback (most recent call last):
File "app.py", line 32, in <module>

    app.run(debug=True)

restore_signals, start_new_session)

File "/usr/lib/python3.6/subprocess.py", line 1344, in > _execute_child

  raise child_exception_type(errno_num, err_msg, err_filename)

OSError: [Errno 8] Exec format error:

/home/haseeb/Documents/Flask/flask_web/app.py

标签: pythonlinuxflask

解决方案


要在 Ubuntu 中启用 Flask 调试,您可以执行以下操作: 为 Flask 设置环境变量:

$ export FLASK_DEBUG=1
$ export app=app.py # change to whatever the filename is

然后通过键入以下命令运行您的 Flask 应用程序:

$ run flask

文档


推荐阅读