阿里云ubuntu利用flask搭建网站问题记录

总目录:Linux操作整理


# flask测试代码
from flask import Flask

app = Flask(__name__)


@app.route('/')
def index():
    return 'hello sayasora!'


if __name__ == '__main__':
    app.run(debug=False,host="0.0.0.0",port=5000)

总思路

https://blog.csdn.net/myli_binbin/article/details/86021623

Virtualenv安装和使用

https://blog.csdn.net/jie6666/article/details/108775486

Virtualenv报错及解决方案

(base) root@sayasora-linux:~# source ~/.bashrc
/root/anaconda3/bin/python: Error while finding module specification for 'virtualenvwrapper.hook_loader' (ModuleNotFoundError: No module named 'virtualenvwrapper')
virtualenvwrapper.sh: There was a problem running the initialization hooks.

If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenvwrapper has been installed for
VIRTUALENVWRAPPER_PYTHON=/root/anaconda3/bin/python and that PATH is
set properly.

https://blog.csdn.net/qq_40187062/article/details/97616059

最后一个运行的坑

原文章最后的命令一直报错,找了半天原因

[2020-11-08 22:32:07 +0800] [6696] [INFO] Starting gunicorn 20.0.4
[2020-11-08 22:32:07 +0800] [6696] [ERROR] Retrying in 1 second.
[2020-11-08 22:32:08 +0800] [6696] [ERROR] Retrying in 1 second.
[2020-11-08 22:32:09 +0800] [6696] [ERROR] Retrying in 1 second.
[2020-11-08 22:32:10 +0800] [6696] [ERROR] Retrying in 1 second.
[2020-11-08 22:32:11 +0800] [6696] [ERROR] Retrying in 1 second.
[2020-11-08 22:32:12 +0800] [6696] [ERROR] Can't connect to ('0.0.0.05000', 8000)

原文章最后的代码为中文冒号,改成英文冒号就行了,其中hello_world:app,hello_world为hello_world.py文件,这儿只需要写hello_world:app。

搭建成功

在这里插入图片描述

阿里云服务器运行后本地访问成功。

以上代码均为其他博主原创,仅对个人遇到的问题进行汇总,希望帮到大家。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值