Create and run a webapp applications.
Allows to create a server and a response system in order to use HTTPD like a communication system between a web-browser and a Python API.
The localhost port is randomly assigned.
Create and run a webapp applications.
Allows to create a server and a response system in order to use HTTPD like a communication system between a web-browser and a Python API.
The localhost port is randomly assigned.
HTTPD Server initialization.
Create the application for a Web Front-End based on HTTPD protocol.
def __init__(self, server_cls):
"""HTTPD Server initialization.
Create the application for a Web Front-End based on HTTPD protocol.
"""
self.__location = 'localhost'
httpd_port = random.randrange(80, 99)
self.__port = httpd_port + httpd_port * 100
self.__server = None
server_address = (self.__location, self.__port)
self.__server = server_cls(server_address, HTTPDHandler)
self.__server.create_pages()
Return the client URL of this server.
def client_url(self) -> str:
"""Return the client URL of this server."""
return 'http://{:s}:{:d}/'.format(self.__location, self.__port)
Run the application with a main loop.
def run(self) -> int:
"""Run the application with a main loop.
:return: (int) Exit status (0=normal)
"""
try:
self.__server.serve_forever()
except KeyboardInterrupt:
self.__server.shutdown()
return 0