from wsgiref.simple_server import make_server from pyramid.config import Configurator from pyramid.response import Response def ip_view(request): body = request.client_addr print(body) return Response(body) port = 6543 with Configurator() as config: config.add_route('ip', '/ip') config.add_view(ip_view, route_name='ip') app = config.make_wsgi_app() server = make_server('0.0.0.0', port, app) print(f'Listen web on port {port}') server.serve_forever()