Newer
Older
# Very basic MEC PLAT simulator
import http.server
import socketserver
import mec_http_server
import threading
import sys, os, time
import msvcrt
# MEC simulator IPv4 address
#ADDRESS_BINDING = '172.28.4.87'
#ADDRESS_BINDING = '192.168.1.21'
#ADDRESS_BINDING = '127.0.0.1'
# MEC simulator IPv4 listening port
PORT_NUMBER = 8081
# TODO Add Linux support for detecting keyboard input from the terminal?
def getch():
""" Capture keybord entry. """
return msvcrt.getch()
# End of function getch
if __name__ == '__main__':
exit = False
try:
# Create a web server and define the handler to manage the incoming request
# server = socketserver.TCPServer((ADDRESS_BINDING, PORT_NUMBER), mec_http_server.myHandler)
server = http.server.HTTPServer((ADDRESS_BINDING, PORT_NUMBER), mec_http_server.myHandler)
server.wbufsize = -1
print ('Started httpserver on port ', PORT_NUMBER)
# Use keybord entries to trigBger notifications
while exit == False:
ch = getch()
if ch == b'\x03':
exit = True