update
This commit is contained in:
@ -15,6 +15,22 @@ from gevent.pywsgi import WSGIServer
|
||||
sys.path.insert(0, ".")
|
||||
|
||||
import detect
|
||||
import logging.config
|
||||
from skywalking import agent, config
|
||||
SW_SERVER = os.environ.get('SW_AGENT_COLLECTOR_BACKEND_SERVICES')
|
||||
SW_SERVICE_NAME = os.environ.get('SW_AGENT_NAME')
|
||||
if SW_SERVER and SW_SERVICE_NAME:
|
||||
config.init() #采集服务的地址,给自己的服务起个名称
|
||||
#config.init(collector="123.60.56.51:11800", service='ieemoo-ai-search') #采集服务的地址,给自己的服务起个名称
|
||||
agent.start()
|
||||
def setup_logging(path):
|
||||
if os.path.exists(path):
|
||||
with open(path, 'r') as f:
|
||||
config = json.load(f)
|
||||
logging.config.dictConfig(config)
|
||||
logger = logging.getLogger("root")
|
||||
return logger
|
||||
logger = setup_logging('utils/logging.json')
|
||||
|
||||
app = Flask(__name__)
|
||||
app.use_reloader=False
|
||||
@ -43,7 +59,7 @@ parser.add_argument('--exist-ok', type=bool, default=True, help='existing projec
|
||||
opt, unknown = parser.parse_known_args()
|
||||
@app.route("/zhanting", methods=['POST'])
|
||||
def get_isempty():
|
||||
start = time.time()
|
||||
#start = time.time()
|
||||
data = request.get_data()
|
||||
ip = request.remote_addr
|
||||
print('------ ip = %s ------' % ip)
|
||||
@ -63,12 +79,14 @@ def get_isempty():
|
||||
file = open(image_path, 'wb')
|
||||
file.write(imgdata)
|
||||
pred = detect.detect(opt)
|
||||
print('pred', pred)
|
||||
getdateend = time.time()
|
||||
now_time = datetime.datetime.now()
|
||||
print('now_time', now_time)
|
||||
print('get date use time: {0:.2f}s'.format(getdateend - start))
|
||||
except:
|
||||
logger.info(pred)
|
||||
#print('pred', pred)
|
||||
#getdateend = time.time()
|
||||
#now_time = datetime.datetime.now()
|
||||
#print('now_time', now_time)
|
||||
#print('get date use time: {0:.2f}s'.format(getdateend - start))
|
||||
except Exception as e:
|
||||
logger.warning(e)
|
||||
return pred
|
||||
|
||||
return pred
|
||||
@ -76,14 +94,6 @@ def get_isempty():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run()
|
||||
app.run(host='192.168.1.142', port=8000)
|
||||
#http_server = WSGIServer(('0.0.0.0', 8000), app)
|
||||
#http_server.serve_forever()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user