bottle
bottle copied to clipboard
redirect function with 500 Internal Server Error
Error: 500 Internal Server Error
Sorry, the requested URL 'http://stock.chenpeng.info/oauth_login' caused an error:
Internal Server Error Exception:
Location: https://api.weibo.com/oauth2/authorize?client_id=2617906645&response_type=code&redirect_uri=http://stock.chenpeng.info/oauth_login_callback&state=zhizuzhefu-6be5a820-94c3-314b-9b92-4688353323a2 Content-Type: text/html; charset=UTF-8 Set-Cookie: oauth_state="!Omsnw7wB5XTeUlGrX96pDQ==?gAJVC29hdXRoX3N0YXRlcQFVL3poaXp1emhlZnUtNmJlNWE4MjAtOTRjMy0zMTRiLTliOTItNDY4ODM1MzMyM2EycQKGcQMu" Traceback:
Traceback (most recent call last): File "/data1/www/htdocs/727/chenpeng/1/stock/system_stock/bottle.py", line 862, in _handle return route.call(*_args) File "/data1/www/htdocs/727/chenpeng/1/stock/system_stock/bottle.py", line 1727, in wrapper rv = callback(_a, **ka) File "/data1/www/htdocs/727/chenpeng/1/stock/app_stock/controller/oauth.py", line 68, in C_oauth_login redirect(target_url) File "/data1/www/htdocs/727/chenpeng/1/stock/system_stock/bottle.py", line 2417, in redirect raise res HTTPResponse
some redirect works fine。
some urls like http to https redirect raise 500 error。
HTTPResponse is not an error, but a valid response trigger. It should be handled by bottle at a very late time but prior to the error handling stuff. Earlier versions of Bottle did it a bit different. Is is possible that you are using an old version of Bottle with a relatively new plugin?
Im using Bottle 0.12。
Hi all,
Same here with version 0.13:
Redirecting to: /
Traceback (most recent call last):
File "...\bottle.py", line 901, in _handle
return route.call(**args)
File "...\bottle.py", line 1822, in wrapper
rv = callback(*a, **ka)
File "./app.py", line 79, in siteLogin
request.POST.get('login-path'))
File "...\lib\util.py", line 65, in login
redirect('/apps')
File "...\lib\bottle.py", line 2448, in redirect
raise res
HTTPResponse
Urban in HTTPERROR: 500
Handling with genericErrorHandler 500
Inside genericErrorHandler
<string>:8: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6
127.0.0.1 - - [13/Jul/2015 10:29:13] "POST /login HTTP/1.1" 500 6647
127.0.0.1 - - [13/Jul/2015 10:29:13] "GET /css/bootstrap.min.css HTTP/1.1" 304 0
127.0.0.1 - - [13/Jul/2015 10:29:13] "GET /css/bootstrap-sky.css HTTP/1.1" 304 0
127.0.0.1 - - [13/Jul/2015 10:29:13] "GET /js/jquery-2.1.4.min.js HTTP/1.1" 304 0
127.0.0.1 - - [13/Jul/2015 10:29:13] "GET /js/bootstrap-3.3.5.min.js HTTP/1.1" 304 0
Is there any workaround?
EDIT 1:
Line 914:bottle.py:
except Exception as e:
print ('Urban in _handle "except Exception"')
print(e.__class__.__name__)
output is:
Urban in _handle "except Exception"
HTTPResponse
Seems like HTTPResponse is not caught! Can it be our setup/paths?
Thanks,
Andreas
I had the same problem, but the reason was, that HTTPResponse and bottle.HTTPResponse came from different bottle files, once from system, once from a local copy. I had one import bottle
instead of import .bottle
.
Good catch. This explains the above error. I'm not sure if/how we can help developers prevent this kind of situation. Importing the same module twice from two different locations could break almost any library. I'm closing this. Please re-open if necessary.