почему автоотладка фляги не работает в Ubuntu - PullRequest
1 голос
/ 31 марта 2019

Когда я запускаю

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

Ответы [ 3 ]

2 голосов
/ 31 марта 2019

лучший Sloution для использования_reloader

if __name__=='__main__':

    app.run(port=5000,debug=True,use_reloader=True)

1 голос
/ 30 апреля 2019

Чтобы включить отладку для Flask в Ubuntu, вы можете сделать следующее: Задайте переменные среды для Flask:

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

Затем запустите приложение Flask, набрав:

$ run flask

Из документов

0 голосов
/ 31 марта 2019

Отступы имеют значение:

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)
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...