mirror of
https://github.com/lightbroker/llmsecops-research.git
synced 2026-03-12 13:27:32 +00:00
python server; add logging
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import json
|
||||
import logging
|
||||
|
||||
from tests.api.controller import ApiController
|
||||
from wsgiref.simple_server import make_server
|
||||
@@ -13,11 +14,14 @@ class RestApiServer:
|
||||
yield [json.dumps({'received': 'data'}).encode('utf-8')]
|
||||
|
||||
def listen(self):
|
||||
port = 9999
|
||||
controller = ApiController()
|
||||
with make_server('', port, controller) as wsgi_srv:
|
||||
print(f'listening on port {port}...')
|
||||
wsgi_srv.serve_forever()
|
||||
try:
|
||||
port = 9999
|
||||
controller = ApiController()
|
||||
with make_server('', port, controller) as wsgi_srv:
|
||||
print(f'listening on port {port}...')
|
||||
wsgi_srv.serve_forever()
|
||||
except Exception as e:
|
||||
logging.warning(e)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user