python项目的运行命令:
ps -aux | grep __init__.py #查看项目运行端口
kill -9 进程id #杀死进程
nohup python3 __init__.py > output2.log 2>&1 & #启动项目(后台启动)
python3 __init__.py #前台启动
jobs #查看运行的所有项目
注意:flask运行部署在服务器时,要保证所有ip都可以访问项目时
需要把运行端口设置为0.0.0.0:而不能写localhost!
if __name__ == "__main__":
app.run('0.0.0.0','8099')
配置跨域:
from flask_cors import CORS
cors = CORS(app, resources={
r"/*"})