Deploy the flask project on the linux server (encounter the bug that the interface cannot be accessed)

The running command of the python project:

ps -aux | grep __init__.py #查看项目运行端口
kill -9 进程id #杀死进程
nohup python3 __init__.py > output2.log 2>&1 & #启动项目(后台启动)
python3 __init__.py #前台启动
jobs #查看运行的所有项目

Note: When flask runs and deploys on the server, ensure that all ips can access the project

The running port needs to be set to 0.0.0.0: instead of localhost!

if __name__ == "__main__":
    app.run('0.0.0.0','8099')

Configure cross-domain:

from flask_cors import CORS
cors = CORS(app, resources={
    
    r"/*"})

Guess you like

Origin blog.csdn.net/m0_58768224/article/details/130036671