mac 系统 下AWS cloud 配置及安装 flask

AWS cloud 管理控制台链接:

https://us-west-2.console.aws.amazon.com/console/home?region=us-west-2

点击控制台账户创建安全凭证




部署flask 官方指引:

http://docs.aws.amazon.com/zh_cn/elasticbeanstalk/latest/dg/create-deploy-python-flask.html

http://docs.amazonaws.cn/elasticbeanstalk/latest/dg/create-deploy-python-flask.html


 tips:不翻墙有可能安装失败

mac端安装python库管理工具pip:

sudo python get-pip.py 


安装 eb cli命令行工具,AWS命令行客户端:

pip install --upgrade --user awsebcli

pip install virtualenv


安装flask:

virtualenv ./eb-virtual

source ./eb-virtual/bin/activate

pip install flask==0.10.1


部署成功效果图:



示例源代码官网提供:

from flask import Flask

# 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))

# run the app.
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()


在AWS 的管理后台, 可以看到创建应用flask-env 成功:





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值