我的意图是 1.执行健康检查,一切正常,但是问题是,我收到此消息http://0.0.0.0:8080/(按CTRL + C退出),对于下一段代码,我必须手动控制c工作
from flask import Flask, request
from flask_restful import Resource, Api
import urllib.request as request
import time
app = Flask(__name__)
api = Api(app)
starttime=time.time()
def example_fun():
print("hello world")
class Health (Resource):
def get(self):
return "UP"
api.add_resource(Health, '/health')
if __name__ == '__main__':
app.run(host='0.0.0.0', port = '8080')
example_fun()
while True:
example_fun()
time.sleep(3)
我期望的是一旦执行app.run(host ='0.0.0.0',port ='8080')并且运行状况良好,它应该继续到example_fun()并开始打印结果,而无需手动执行控制+ c