A small project: visit a URL, automatically generate a PDF. After deploying it to the company’s server with flaks, it is normal to work after connecting to VPN, but if the VPN is disconnected and reconnected to VPN, the URL cannot be accessed and the flask service must be restarted. Excuse meOnce the service is released, it will always be available if it is connected to VPN (even if it is broken and reconnected again).
if __name__ == '__main__': app.run(debug=True,host='0.0.0.0',port=5000)
You can consider script implementation, VPN connection and flask startup in a script. When the VPN connection is successful, execute the statement that starts flask, such as
python path/to/run.py。Provide a way of thinking…
if __name__ == '__main__': app.run(threaded=True,host='0.0.0.0',port=5000)
I think it may be related to the implementation of flask, plus debug. Recommend uwsgi, nginx try.