问题一

Could not locate a Flask application. You did not provide the "FLASK_APP" environment variable, and a "wsgi.py" or "app.py" module was not found in the current directory.

解决

将app.py放在当前根目录下,输入pwd就可以知道当前根目录

问题二

NoAppException: Could not locate a Flask application. You did not provide the "FLASK_APP" environment variable, and a "wsgi.py" or "app.py" module was not found in the current directory.

解决

在之前的目录下有 .env 或 .flaskenv 文件,删除即可

问题三

socket.error: [Errno 48] Address already in use

解决

用$ sudo lsof -i:5000 查看进程,然后杀死进程sudo kill #pid。

问题四

出现了CSS文件没有渲染的问题

解决

from datetime import timedelta

# 设置静态文件缓存过期时间
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = timedelta(seconds=1)

# 也可以这样写:
app.send_file_max_age_default = timedelta(seconds=1)

rel 要写icon。不能自己编!!!

问题五

SyntaxError: Non-ASCII character '\xe7' in file /Users/Huizhi/watchlist/app.py on line 50, but no encoding declared;

解决

在文件app.py前面加# -- coding: utf-8 -

问题六

global name 'redirect' is not defined

解决

from flask import redirect