总目录:Linux操作整理
阿里云ubuntu利用flask搭建网站问题记录
# 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.0:5000', 8000)
原文章最后的代码为中文冒号,改成英文冒号就行了,其中hello_world:app,hello_world为hello_world.py文件,这儿只需要写hello_world:app。
搭建成功
阿里云服务器运行后本地访问成功。
以上代码均为其他博主原创,仅对个人遇到的问题进行汇总,希望帮到大家。