Python Forum
malformed header from script 'main.py': Bad header: * Serving Flask app "main"
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
malformed header from script 'main.py': Bad header: * Serving Flask app "main"
#1
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.
Reply
#2
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)
Reply
#3
Thanks... Tried as suggested.. but it's the same issue
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  digest header generating issue alexander_pershin 1 1,318 Mar-20-2023, 08:11 AM
Last Post: wnesbv
  gettin flask to call script periodically GrahamL 1 2,180 Jan-08-2021, 06:11 PM
Last Post: ndc85430
  Django serving wrong template at the wrong address with malformed urls.py (redactor a Drone4four 2 2,531 Aug-17-2020, 01:09 PM
Last Post: Drone4four
  Need Help Getting Request Response From Main URL samlee916 3 1,907 Jul-18-2020, 04:28 AM
Last Post: scidam
  Unable to switch out of nested frames into main page abi17124 0 1,839 Jul-17-2019, 06:06 PM
Last Post: abi17124
  Serving mixed filenames with send_from_directory() errors out. nikos 0 1,857 Sep-20-2018, 03:11 AM
Last Post: nikos
  Connecting python script into HTML with flask Piqurs 1 16,049 Sep-05-2018, 08:24 PM
Last Post: snippsat
  In CSV, how to write the header after writing the body? Tim 18 14,419 Jan-06-2018, 01:54 PM
Last Post: Larz60+
  urllib2.urlopen() user agent header Skaperen 8 12,548 Jul-14-2017, 05:36 PM
Last Post: nilamo
  HTTP Header request, how to improve efficiency andreamoro 5 5,056 May-01-2017, 03:49 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020