Reputation: 2101
When I run
python app.py
where content of app.py
is:
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)
I get the following error:
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
Upvotes: 1
Views: 1042
Reputation: 29
This worked for me: On terminal before running flask, run the following commands:
$ export FLASK_DEBUG=1
$ export app=app.py
Then:
flask run
Upvotes: 0
Reputation: 2101
if __name__=='__main__':
app.run(port=5000,debug=True,use_reloader=True)
Upvotes: 2
Reputation: 483
To enable debugging for Flask in Ubuntu you can do the following: Set environment variables for Flask:
$ export FLASK_DEBUG=1
$ export app=app.py # change to whatever the filename is
Then run your Flask-app by typing:
$ run flask
From the docs
Upvotes: 3
Reputation: 4537
Indentation matters:
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)
Upvotes: 0