Refactor Docker Compose examples and plugins, add pytest tests
- Adjusted Compose files to build images locally instead of pulling. - Simplified examples by removing `/etc/hosts` entry instructions. - Enhanced `cloudflare.py` plugin with a configurable log format. - Improved `generate-keys.sh` for portability using `$SCRIPT_DIR`. - Added end-to-end tests for Compose examples using pytest.
This commit is contained in:
parent
343987ab58
commit
5767e55dea
19 changed files with 1162 additions and 89 deletions
33
examples/docker/python-app/server.py
Normal file
33
examples/docker/python-app/server.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Simple HTTP server that echoes all request headers"""
|
||||
|
||||
from http.server import HTTPServer, BaseHTTPRequestHandler
|
||||
import json
|
||||
|
||||
class HeaderEchoHandler(BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
self.send_response(200)
|
||||
self.send_header('Content-Type', 'application/json')
|
||||
self.end_headers()
|
||||
|
||||
# Collect all headers
|
||||
headers = dict(self.headers)
|
||||
|
||||
# Add the client IP as seen by this server
|
||||
response = {
|
||||
'headers': headers,
|
||||
'client_ip': self.client_address[0],
|
||||
'x_forwarded_for': self.headers.get('X-Forwarded-For', 'NOT SET')
|
||||
}
|
||||
|
||||
self.wfile.write(json.dumps(response, indent=2).encode())
|
||||
|
||||
def log_message(self, format, *args):
|
||||
# Log to stdout
|
||||
print(f"{self.address_string()} - {format % args}")
|
||||
|
||||
if __name__ == '__main__':
|
||||
port = 8080
|
||||
server = HTTPServer(('0.0.0.0', port), HeaderEchoHandler)
|
||||
print(f'Header echo server running on port {port}...')
|
||||
server.serve_forever()
|
||||
Loading…
Add table
Add a link
Reference in a new issue