What is the meaning of "#! Flask / bin / python" in flask?
why is this line #!flask/bin/python
added at the top of this code?
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return "Hello, World!"
if __name__ == '__main__':
app.run(debug=True)
I got the following error when I removed it
from: can't read /var/mail/flask
./app.py: line 3: syntax error near unexpected token `('
./app.py: line 3: `app = Flask(__name__)'
+3
Raghav Mittal
source
to share
1 answer
#!
is shebang
. On UNIX / UNIX, like operating systems, it basically tells your shell an executable (python in your case) to execute the script with. Without it, the shell executes the script directly, and since it doesn't understand Python code, it throws an error.
+4
uname01
source
to share