Skip to content

Commit 324f3d5

Browse files
committed
Adds Framewalk (multi) Labs (sanic, cherrypy, starllete, tornado, web2py)
1 parent 7a0b443 commit 324f3d5

16 files changed

+915
-49
lines changed

core/labs/vmnf_labs.py

Lines changed: 315 additions & 49 deletions
Large diffs are not rendered by default.

siddhis/framewalk/lab/Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM python:3.9-slim
2+
3+
WORKDIR /app
4+
5+
# Install curl for healthcheck
6+
RUN apt-get update && \
7+
apt-get install -y curl && \
8+
apt-get clean && \
9+
rm -rf /var/lib/apt/lists/*
10+
11+
# Copy requirements first for better caching
12+
COPY requirements.txt .
13+
RUN pip install --no-cache-dir -r requirements.txt
14+
15+
# Copy application code
16+
COPY . .
17+
18+
# Expose the application port
19+
EXPOSE 8000
20+
21+
# Run the application
22+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM python:3.9-slim
2+
3+
WORKDIR /app
4+
5+
# Install system dependencies
6+
RUN apt-get update && apt-get install -y \
7+
gcc \
8+
&& rm -rf /var/lib/apt/lists/*
9+
10+
# Install CherryPy
11+
RUN pip install cherrypy
12+
13+
# Copy the CherryPy application
14+
COPY cherrypy_app.py /app/
15+
16+
# Create session directory
17+
RUN mkdir -p /tmp/cherrypy_sessions
18+
19+
# Expose port
20+
EXPOSE 8080
21+
22+
# Run the CherryPy application
23+
CMD ["python", "cherrypy_app.py"]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM python:3.9-slim
2+
3+
WORKDIR /app
4+
5+
# Copy the application file
6+
COPY sanic_app.py /app/
7+
8+
# Install sanic
9+
RUN pip install sanic
10+
11+
# Expose port
12+
EXPOSE 8080
13+
14+
# Run the application
15+
CMD ["python", "sanic_app.py"]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM python:3.9-slim
2+
3+
WORKDIR /app
4+
5+
# Install Starlette and Uvicorn
6+
RUN pip install starlette uvicorn
7+
8+
# Copy the application file
9+
COPY starlette_app.py /app/
10+
11+
# Expose port
12+
EXPOSE 8080
13+
14+
# Run the application
15+
CMD ["python", "starlette_app.py"]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM python:3.9-slim
2+
3+
WORKDIR /app
4+
5+
# Copy the application file
6+
COPY tornado_app.py /app/
7+
8+
# Install tornado
9+
RUN pip install tornado
10+
11+
# Expose port
12+
EXPOSE 8080
13+
14+
# Run the application
15+
CMD ["python", "tornado_app.py"]
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM python:3.9-slim
2+
3+
WORKDIR /app
4+
5+
# Install system dependencies
6+
RUN apt-get update && apt-get install -y \
7+
gcc \
8+
wget \
9+
unzip \
10+
&& rm -rf /var/lib/apt/lists/*
11+
12+
# Download and extract web2py (using --no-check-certificate to bypass SSL issues)
13+
RUN wget --no-check-certificate https://www.web2py.com/examples/static/web2py_src.zip && \
14+
unzip web2py_src.zip && \
15+
rm web2py_src.zip
16+
17+
# Copy the minimal app script
18+
COPY web2py_app.py /app/
19+
20+
# Expose port
21+
EXPOSE 8080
22+
23+
# Run the minimal app (which will use the extracted web2py)
24+
CMD ["python", "web2py_app.py"]
25+
26+
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
#!/usr/bin/env python3
2+
"""
3+
CherryPy Test Application for Framework Detection
4+
"""
5+
6+
import cherrypy
7+
import os
8+
9+
class CherryPyTestApp:
10+
@cherrypy.expose
11+
def index(self):
12+
return """
13+
<!DOCTYPE html>
14+
<html>
15+
<head>
16+
<title>CherryPy Test App</title>
17+
</head>
18+
<body>
19+
<h1>Hello from CherryPy!</h1>
20+
<p>CherryPy Framework Detection Test</p>
21+
<p>CherryPy is a pythonic, object-oriented HTTP framework.</p>
22+
<ul>
23+
<li><a href="/about">About</a></li>
24+
<li><a href="/api/status">API Status</a></li>
25+
<li><a href="/error">Test Error</a></li>
26+
<li><a href="/admin">Admin Interface</a></li>
27+
</ul>
28+
</body>
29+
</html>
30+
""".encode('utf-8')
31+
32+
@cherrypy.expose
33+
def about(self):
34+
return """
35+
<!DOCTYPE html>
36+
<html>
37+
<head>
38+
<title>About - CherryPy Test App</title>
39+
</head>
40+
<body>
41+
<h1>About CherryPy</h1>
42+
<p>CherryPy is a pythonic, object-oriented HTTP framework.</p>
43+
<p>It allows developers to build web applications in much the same way they would build any other object-oriented Python program.</p>
44+
<a href="/">Back to Home</a>
45+
</body>
46+
</html>
47+
""".encode('utf-8')
48+
49+
@cherrypy.expose
50+
def api(self, status=None):
51+
if status == "status":
52+
cherrypy.response.headers['Content-Type'] = 'application/json'
53+
return '{"framework": "cherrypy", "status": "running", "version": "18.8.0"}'.encode('utf-8')
54+
return "API endpoint".encode('utf-8')
55+
56+
@cherrypy.expose
57+
def error(self):
58+
# Trigger an error for testing
59+
raise cherrypy.HTTPError(500, "Test error for framework detection")
60+
61+
@cherrypy.expose
62+
def admin(self):
63+
return """
64+
<!DOCTYPE html>
65+
<html>
66+
<head>
67+
<title>CherryPy Admin</title>
68+
</head>
69+
<body>
70+
<h1>CherryPy Admin Interface</h1>
71+
<p>This is the CherryPy admin interface for testing.</p>
72+
<p>CherryPy admin features:</p>
73+
<ul>
74+
<li>Session management</li>
75+
<li>Configuration</li>
76+
<li>Logging</li>
77+
</ul>
78+
<a href="/">Back to Home</a>
79+
</body>
80+
</html>
81+
""".encode('utf-8')
82+
83+
if __name__ == '__main__':
84+
# Configure CherryPy
85+
cherrypy.config.update({
86+
'server.socket_host': '0.0.0.0',
87+
'server.socket_port': 8080,
88+
'server.thread_pool': 10,
89+
'tools.sessions.on': True,
90+
'tools.sessions.storage_type': 'file',
91+
'tools.sessions.storage_path': '/tmp/cherrypy_sessions',
92+
'log.screen': True,
93+
'log.access_file': '/tmp/cherrypy_access.log',
94+
'log.error_file': '/tmp/cherrypy_error.log'
95+
})
96+
97+
# Mount the application
98+
cherrypy.quickstart(CherryPyTestApp(), '/')
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
echo "🧹 Cleaning up Framework Test Lab..."
4+
5+
# Stop and remove containers
6+
echo "🛑 Stopping containers..."
7+
docker-compose -f docker-compose.yml down
8+
9+
# Remove any dangling images
10+
echo "🗑️ Cleaning up images..."
11+
docker image prune -f
12+
13+
echo "✅ Framework Test Lab cleaned up!"
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
version: '3.8'
2+
3+
services:
4+
web2py-app:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile.web2py
8+
container_name: web2py-test-app
9+
ports:
10+
- "8081:8080"
11+
restart: unless-stopped
12+
environment:
13+
- PYTHONUNBUFFERED=1
14+
15+
sanic-app:
16+
build:
17+
context: .
18+
dockerfile: Dockerfile.sanic
19+
container_name: sanic-test-app
20+
ports:
21+
- "8082:8080"
22+
restart: unless-stopped
23+
environment:
24+
- PYTHONUNBUFFERED=1
25+
26+
tornado-app:
27+
build:
28+
context: .
29+
dockerfile: Dockerfile.tornado
30+
container_name: tornado-test-app
31+
ports:
32+
- "8083:8080"
33+
restart: unless-stopped
34+
environment:
35+
- PYTHONUNBUFFERED=1
36+
37+
starlette-app:
38+
build:
39+
context: .
40+
dockerfile: Dockerfile.starlette
41+
container_name: starlette-test-app
42+
ports:
43+
- "8084:8080"
44+
restart: unless-stopped
45+
environment:
46+
- PYTHONUNBUFFERED=1
47+
48+
cherrypy-app:
49+
build:
50+
context: .
51+
dockerfile: Dockerfile.cherrypy
52+
container_name: cherrypy-test-app
53+
ports:
54+
- "8085:8080"
55+
restart: unless-stopped
56+
environment:
57+
- PYTHONUNBUFFERED=1

0 commit comments

Comments
 (0)