Shad Ansari | 6fcfa29 | 2022-01-28 00:34:13 +0000 | [diff] [blame^] | 1 | """ |
| 2 | SPDX-FileCopyrightText: 2020-present Open Networking Foundation <info@opennetworking.org> |
| 3 | SPDX-License-Identifier: LicenseRef-ONF-Member-1.01 |
| 4 | """ |
| 5 | import sys |
| 6 | |
Shad Ansari | 1dcfdb3 | 2022-01-24 23:13:06 +0000 | [diff] [blame] | 7 | from flask import Flask, request |
| 8 | from flask_restful import Resource, Api |
Shad Ansari | 6fcfa29 | 2022-01-28 00:34:13 +0000 | [diff] [blame^] | 9 | import logging as log |
Shad Ansari | 1dcfdb3 | 2022-01-24 23:13:06 +0000 | [diff] [blame] | 10 | |
| 11 | app = Flask(__name__) |
| 12 | api = Api(app) |
| 13 | |
Shad Ansari | 6fcfa29 | 2022-01-28 00:34:13 +0000 | [diff] [blame^] | 14 | |
| 15 | class Greeting(Resource): |
Shad Ansari | 1dcfdb3 | 2022-01-24 23:13:06 +0000 | [diff] [blame] | 16 | def get(self): |
| 17 | return 'Hello World!' |
| 18 | |
Shad Ansari | 6fcfa29 | 2022-01-28 00:34:13 +0000 | [diff] [blame^] | 19 | |
| 20 | api.add_resource(Greeting, '/') # Route_1 |
Shad Ansari | 1dcfdb3 | 2022-01-24 23:13:06 +0000 | [diff] [blame] | 21 | |
| 22 | if __name__ == '__main__': |
Shad Ansari | 6fcfa29 | 2022-01-28 00:34:13 +0000 | [diff] [blame^] | 23 | log.basicConfig( |
| 24 | format='%(asctime)s %(levelname)-8s %(message)s', |
| 25 | level=log.DEBUG, |
| 26 | datefmt='%Y-%m-%d %H:%M:%S', |
| 27 | stream=sys.stdout) |
| 28 | |
| 29 | log.info("Starting network-diag-app...") |
| 30 | |
| 31 | app.run('0.0.0.0', '3333') |