flask环境配置
安装flask:
pip install Flask
pip install Flask-SQLAlchemy
flask demo
在PyCharm中创建项目,并新建 app.py 内容如下:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello, World!'
if __name__ == '__main__':
app.run(debug=True)
运行 app.py,出现如下报错:
Traceback (most recent call last):
File "E:\code\python\test_flask_0\app.py", line 10, in <module>
app.run(debug=True)
File "C:\Users\Asus\AppData\Roaming\Python\Python311\site-packages\flask\app.py", line 625, in run
run_simple(t.cast(str, host), port, self, **options)
File "C:\Users\Asus\AppData\Roaming\Python\Python311\site-packages\werkzeug\serving.py", line 1106, in run_simple
run_with_reloader(
File "C:\Users\Asus\AppData\Roaming\Python\Python311\site-packages\werkzeug\_reloader.py", line 442, in run_with_reloader
reloader = reloader_loops[reloader_type](
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Asus\AppData\Roaming\Python\Python311\site-packages\werkzeug\_reloader.py", line 315, in __init__
from watchdog.events import EVENT_TYPE_OPENED
ImportError: cannot import name 'EVENT_TYPE_OPENED' from 'watchdog.events' (C:\ProgramData\anaconda3\Lib\site-packages\watchdog\events.py)
出现该问题是因为 flask 与 watchdog 版本不兼容,更新 watchdog 即可解决:
pip install --upgrade watchdog
vue环境配置
安装 nodejs:
去nodejs官网下载安装包,并一路按照默认配置安装即可。
安装完成后,在命令行中运行如下命令确认nodejs是否安装成功:
node -v
安装 cnpm:
npm install -g cnpm --registry=https://registry.npm.taobao.org
我这边按照 cnpm 一直出现如下报错:
npm ERR! code CERT_HAS_EXPIRED
npm ERR! errno CERT_HAS_EXPIRED
npm ERR! request to https://registry.npm.taobao.org/cnpm failed, reason: certificate has expired
npm ERR! A complete log of this run can be found in: C:\Users\Asus\AppData\Local\npm-cache\_logs\2024-05-08T12_31_24_034Z-debug-0.log
尝试解决无果,故只得跳过这一步,进入后续步骤(如果安装成功,后续按照命令中的“npm”可以改成“cnpm”)
安装 vue-cli:
npm install -g @vue/cli
运行如下命令测试vue是否安装成功:
vue -v
vue demo
创建vue项目
在命令行中,切换到要创建项目的目录,运行如下命令:
vue create test_vue_0
运行 vue demo:
cd test_vue_0
npm run serve
在浏览器中输入“http://localhost:8080/”即可访问demo页面。