python小技巧(二) 使用花生壳+WSGI发布flask程序

16 篇文章 4 订阅
12 篇文章 0 订阅

使用花生壳+wsgi发布flask程序

下载WSGI

pip install gevent   // 使用pip
// 或
conda install gevent  // 使用conda

下载花生壳

进入下载地址,下载安装包、安装后打开

创建映射

首先登录,点一下加号:

创建应用(花6块):

点一下保存:

其中400029f86z.wicp.vip是你的域名

测试

新建app.py,编写一个hello world:

from flask import Flask

app = Flask(__name__)

@app.route('/')
def index():
	return 'hello world'
	
if __name__ == '__main__':
	app.run(port=7000)

在同级目录下新建wsgi.py

from gevent.pywsgi import WSGIServer
from app import app

if __name__ == '__main__':
    WSGIServer(('127.0.0.1', 7000), app).serve_forever()

运行:

python wsgi.py

效果

打开浏览器输入http://400029f86z.wicp.vip:34049(把400029f86z.wicp.vip:34049替换为你的域名)


并且在外网也可访问

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值