Python Forum

Full Version: malformed header from script 'main.py': Bad header: * Serving Flask app "main"
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi All,

I am trying to host a simple python application to test. But while running the app from browser I am getting the below error.

[pid 3952] malformed header from script 'main.py': Bad header: * Serving Flask app "main" (l

[pid 3952] AH01215: Traceback (most recent call last):

[pid 3952] AH01215: File "/var/www/html/testFolder/main.py", line 14, in

[pid 3952] AH01215: app.run()

[pid 3952] AH01215: File "/var/www/html/testFolder/vnv_testFolder/lib/python3.6/site-packages/flask/app.py", line 944, in run

[pid 3952] AH01215: run_simple(host, port, self, **options)

[pid 3952] AH01215: File "/var/www/html/testFolder/vnv_testFolder/lib/python3.6/site-packages/werkzeug/serving.py", line 987, in run_simple

[pid 3952] AH01215: s.bind(server_address)

[pid 3952] AH01215: PermissionError: [Errno 13] Permission denied

Below is my python code (main.py)

#!/var/www/html/testFolder/vnv_testFolder/bin/python3

from flask import Flask

app = Flask(__name__)
app.debug = True
app.secret_key = 'developmentkey'

@app.route("/")
def home():
return "Hello World!"

if __name__ == "__main__":
app.run()
I am using RHEL 7 with python 3.

Please suggest if i am doing something wrong.
I don't know if it makes a difference but I would do this:
from flask import Flask
app = Flask(__name__)
app.config[SECRET_KEY] = 'developmentkey'

@app.route('/')
def home():
    return "Hello World"

if __name__ == "__main__":
    app.run(debug=True)
Thanks... Tried as suggested.. but it's the same issue