Reputation: 2587
I am using Flask and Apache to build a website and the site is up and running.
However I met this strange 500 error: one 500 error will take the website down, and the site will never come online again until I restart apache. I expect Flask+Apache can serve the next visitor after the 500 error, anyway, Flask is thread local.
Assuming the following occassion:
@app.route('/<ExpectSomeInteger>')
def hello_world(ExpectSomeInteger):
aNumber = int(ExpectSomeInteger)
.....
Obviously the code above is faulty and it should use <int:ExpectSomeInteger>
and stuff.
If some visitor typed some letters in the "ExpectSomeInteger"'s place, then flask will return a 500 error.
The disaster is apache will send a 500 error page to all visitors after that! I can only restart apache to make it work again!
Is it normal?
I remember when I visit some PHP+MySQL site, even after some very serious errors, the site can serve the next visitor as normal.
Upvotes: 1
Views: 1053
Reputation: 2587
Thanks to @Sasha Chedygov and my site is working fine now.
The problem is I installed something called "mod-python" by following Linode's Library: https://library.linode.com/web-servers/apache/installation/ubuntu-10.04-lucid
After I did "apt-get remove libapache2-mod-python", Everything seems fine now.
Upvotes: 1
Reputation: 298048
Pass a type converter into the route:
@app.route('/<int:an_integer>')
def hello_world(an_integer):
...
Now, an_integer
is guaranteed to be an integer. When you pass anything other than an integer, a 404 response is sent.
Upvotes: 0