我的目标是能够在一个带有弹性beanstalk服务器的烧瓶web-app中使用beutifulsoup4和Python3.4,并且能够在我的主脚本中使用beautifulsoup。我成功地获得了一个带有flask和python 3.4的弹性beanstalk web应用程序并使用此代码顺利运行:
from flask import Flask
import time
# print a nice greeting.
def say_hello(username = "World"):
return '<p>Hello %s!</p>\n' % username
# some bits of text for the page.
header_text = '''
<html>\n<head> <title>EB Flask Test</title> </head>\n<body>'''
instructions = '''
<p><em>Hint</em>: This is a RESTful web service! Append a username
to the URL (for example: <code>/Thelonious</code>) to say hello to
someone specific.</p>\n'''
home_link = '<p><a href="/">Back</a></p>\n'
footer_text = '</body>\n</html>'
# EB looks for an 'application' callable by default.
application = Flask(__name__)
# add a rule for the index page.
application.add_url_rule('/', 'index', (lambda: header_text +
say_hello() + instructions + footer_text))
# add a rule when the page is accessed with a name appended to the site
# URL.
application.add_url_rule('/<username>', 'hello', (lambda username:
header_text + say_hello(username) + home_link + footer_text))
if __name__ == "__main__":
# Setting debug to True enables debug output. This line should be
# removed before deploying a production app.
application.debug = True
application.run()
需求文件如下所示:
flask==0.12.2
beautifulsoup4==4.6
lxml==4.1
直到这一点,每件事都没有错误,但是一旦我在python代码的第3行导入beautifulsoup,网页就会给我这个错误:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable
to complete your request.
Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
如果有人能够提供建议或让我知道我是否有广泛的请求让我知道:)
再次感谢,约翰D.