X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=near-rt-ric-simulator%2Fsrc%2FSTD_2.0.0%2Fmain.py;h=3057169b613d1021c04ff85de464956f790d9bc2;hb=d9b25321d9bce8a3db88102c127e2aa4436d81c8;hp=16e4a31a505947c8766e7419c085a7a0508cdcfe;hpb=24ee2701e54884c8fc2ed7e6cf522d71286a3b33;p=sim%2Fa1-interface.git diff --git a/near-rt-ric-simulator/src/STD_2.0.0/main.py b/near-rt-ric-simulator/src/STD_2.0.0/main.py index 16e4a31..3057169 100644 --- a/near-rt-ric-simulator/src/STD_2.0.0/main.py +++ b/near-rt-ric-simulator/src/STD_2.0.0/main.py @@ -1,5 +1,6 @@ # ============LICENSE_START=============================================== -# Copyright (C) 2021 Nordix Foundation. All rights reserved. +# Copyright (C) 2023 Nordix Foundation. All rights reserved. +# Copyright (C) 2023 OpenInfra Foundation Europe. All rights reserved. # ======================================================================== # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,6 +17,7 @@ # import connexion +import uvicorn import json import sys import os @@ -23,13 +25,15 @@ import requests from pathlib import Path -from flask import Flask, escape, request, Response +from flask import Flask, request, Response from jsonschema import validate from var_declaration import policy_instances, policy_types, policy_status, callbacks, forced_settings, policy_fingerprint, hosts_set, data_delivery_counter, app from maincommon import check_apipath, apipath, get_supported_interfaces_response, extract_host_name -#Constants +# Constants TEXT_PLAIN='text/plain' +APPL_JSON='application/json' + check_apipath() @@ -197,8 +201,7 @@ def sendstatus(): if (resp.status_code<199 & resp.status_code > 299): return Response('Post status failed with code: '+resp.status_code, status=500, mimetype=TEXT_PLAIN) - data = resp.json() - return Response(data, 200, mimetype='application/json') + return Response(None, 204, mimetype=APPL_JSON) #Receive status (only for testing callbacks) #/statustest @@ -210,7 +213,7 @@ def statustest(): except Exception: return Response("The status data is corrupt or missing.", 400, mimetype=TEXT_PLAIN) - return Response(json.dumps(data), 200, mimetype='application/json') + return Response(json.dumps(data), 200, mimetype=APPL_JSON) #Receive a data delivery package #/datadelivery @@ -251,7 +254,6 @@ if len(sys.argv) >= 2: if isinstance(sys.argv[1], int): port_number = sys.argv[1] -app.add_api('ORAN_A1-p_V2.0.0_api.yaml') - if __name__ == '__main__': - app.run(port=port_number, host="127.0.0.1", threaded=False) \ No newline at end of file + # Use Uvicorn to run the combined app + uvicorn.run(app, host="127.0.0.1", port=port_number, log_level="info") \ No newline at end of file