Skip to content

Commit 0ef37e3

Browse files
authored
Merge pull request #1 from EvanCasey13/master
Initial commit
2 parents 14c20b6 + a0cc233 commit 0ef37e3

12 files changed

Lines changed: 2869 additions & 1 deletion

File tree

‎.containerignore‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Virtual environment
2+
venv/
3+
.venv/
4+
env/
5+
6+
# Python cache
7+
__pycache__/
8+
*.py[cod]
9+
*$py.class
10+
*.pyo
11+
12+
# IDE
13+
.idea/
14+
.vscode/
15+
*.swp
16+
*.swo
17+
18+
# Git
19+
.git/
20+
.gitignore
21+
22+
# Misc
23+
*.md
24+
*.log
25+
.DS_Store
26+
Thumbs.db

‎Containerfile‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Python Workshop Container
2+
# Build: podman build -t python-workshop .
3+
# Run: podman run -p 5000:5000 python-workshop
4+
5+
FROM registry.access.redhat.com/ubi9/python-311:latest
6+
7+
LABEL maintainer="Red Hat Python Workshop"
8+
LABEL description="Interactive Python learning application"
9+
10+
# Set working directory
11+
WORKDIR /app
12+
13+
# Copy requirements first for better layer caching
14+
COPY requirements.txt .
15+
16+
# Install dependencies
17+
RUN pip install --no-cache-dir -r requirements.txt
18+
19+
# Download TextBlob corpora (needed for NLP features)
20+
RUN python -c "import nltk; nltk.download('punkt'); nltk.download('averaged_perceptron_tagger')"
21+
22+
# Copy application files
23+
COPY app.py .
24+
COPY templates/ templates/
25+
COPY static/ static/
26+
27+
# Expose port
28+
EXPOSE 5000
29+
30+
# Environment variables for Flask
31+
ENV FLASK_HOST=0.0.0.0
32+
ENV FLASK_PORT=5000
33+
ENV FLASK_DEBUG=false
34+
35+
# Run the application
36+
CMD ["python", "app.py"]

‎README.md‎

Lines changed: 325 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,325 @@
1-
# python_plc_workshop
1+
# Red Hat Python Workshop
2+
3+
A beginner-friendly Flask web application for teaching Python.
4+
5+
## Features
6+
7+
- **16 Interactive Lessons** covering Python basics through real AI tools
8+
- **Run code in the browser** - see output instantly
9+
- **Exercises with hints** - practice each concept
10+
- **Scratch pad** - experiment with your own code
11+
- **Quick reference** - cheat sheet for common syntax
12+
- **Real AI tools** - TextBlob, scikit-learn
13+
14+
## Lessons
15+
16+
1. **Python Basics**
17+
- Hello World
18+
- Variables
19+
- Data Types
20+
- Operators
21+
- User Input
22+
23+
2. **Control Flow**
24+
- If Statements
25+
- For Loops
26+
- While Loops
27+
28+
3. **Data Structures**
29+
- Lists
30+
- Dictionaries
31+
32+
4. **Functions**
33+
- Defining Functions
34+
- Advanced Functions
35+
36+
5. **Real AI Tools**
37+
- Sentiment Analysis (TextBlob - detect emotions in text)
38+
- Spam Detector (scikit-learn - train a real ML model)
39+
- Text Analysis (Extract nouns, verbs, topics)
40+
- Movie Recommender (Build a Netflix-style system)
41+
42+
## Setup
43+
44+
Choose your operating system below and follow the instructions.
45+
46+
---
47+
48+
### Windows
49+
50+
#### Option 1: Command Prompt (cmd)
51+
52+
```cmd
53+
# Check Python is installed
54+
python --version
55+
56+
# Create virtual environment
57+
python -m venv venv
58+
59+
# Activate virtual environment
60+
venv\Scripts\activate
61+
62+
# Install dependencies
63+
pip install -r requirements.txt
64+
65+
# Run the app
66+
python app.py
67+
```
68+
69+
#### Option 2: PowerShell
70+
71+
```powershell
72+
# Check Python is installed
73+
python --version
74+
75+
# Create virtual environment
76+
python -m venv venv
77+
78+
# Activate virtual environment
79+
.\venv\Scripts\Activate.ps1
80+
81+
# Install dependencies
82+
pip install -r requirements.txt
83+
84+
# Run the app
85+
python app.py
86+
```
87+
88+
> **Note:** If you get a PowerShell execution policy error, run:
89+
> `Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser`
90+
91+
#### Windows Quick Start (one command)
92+
```cmd
93+
python -m venv venv && venv\Scripts\activate && pip install -r requirements.txt && python app.py
94+
```
95+
96+
---
97+
98+
### macOS
99+
100+
```bash
101+
# Check Python is installed
102+
python3 --version
103+
104+
# Create virtual environment
105+
python3 -m venv venv
106+
107+
# Activate virtual environment
108+
source venv/bin/activate
109+
110+
# Install dependencies
111+
pip install -r requirements.txt
112+
113+
# Run the app
114+
python app.py
115+
```
116+
117+
#### macOS Quick Start (one command)
118+
```bash
119+
python3 -m venv venv && source venv/bin/activate && pip install -r requirements.txt && python app.py
120+
```
121+
122+
> **Note:** macOS uses `python3` instead of `python`. If you don't have Python, install it with:
123+
> `brew install python` (requires [Homebrew](https://brew.sh))
124+
125+
---
126+
127+
### Linux (Ubuntu/Debian)
128+
129+
```bash
130+
# Install Python and venv if needed
131+
sudo apt update
132+
sudo apt install python3 python3-venv python3-pip
133+
134+
# Check Python is installed
135+
python3 --version
136+
137+
# Create virtual environment
138+
python3 -m venv venv
139+
140+
# Activate virtual environment
141+
source venv/bin/activate
142+
143+
# Install dependencies
144+
pip install -r requirements.txt
145+
146+
# Run the app
147+
python app.py
148+
```
149+
150+
#### Linux Quick Start (one command)
151+
```bash
152+
python3 -m venv venv && source venv/bin/activate && pip install -r requirements.txt && python app.py
153+
```
154+
155+
---
156+
157+
### Podman (Container)
158+
159+
Run the application in a container without installing Python dependencies locally.
160+
161+
#### Windows (PowerShell)
162+
163+
```powershell
164+
# First time only - initialize and start the Podman machine
165+
podman machine init
166+
podman machine start
167+
168+
# Build and run
169+
podman build -t python-workshop .
170+
podman run -p 5000:5000 python-workshop
171+
```
172+
173+
Quick start (after machine is running):
174+
```powershell
175+
podman build -t python-workshop . ; podman run -p 5000:5000 python-workshop
176+
```
177+
178+
Then open http://localhost:5000
179+
180+
#### WSL (Windows Subsystem for Linux)
181+
182+
```bash
183+
# Build the image
184+
podman build -t python-workshop .
185+
186+
# Run with host networking (required for WSL)
187+
podman run --network=host python-workshop
188+
```
189+
190+
Then open http://localhost:5000
191+
192+
#### macOS
193+
194+
```bash
195+
# First time only - initialize and start the Podman machine
196+
podman machine init
197+
podman machine start
198+
199+
# Build and run
200+
podman build -t python-workshop . && podman run -p 5000:5000 python-workshop
201+
```
202+
203+
Then open http://localhost:5000
204+
205+
#### Linux
206+
207+
```bash
208+
# No machine needed - Podman runs natively
209+
podman build -t python-workshop . && podman run -p 5000:5000 python-workshop
210+
```
211+
212+
Then open http://localhost:5000
213+
214+
#### Run in Background
215+
216+
```bash
217+
podman run -d -p 5000:5000 --name workshop python-workshop
218+
podman logs workshop # View logs
219+
podman stop workshop # Stop
220+
podman rm workshop # Remove
221+
```
222+
223+
#### Different Port
224+
225+
```bash
226+
podman run -p 8080:5000 python-workshop
227+
```
228+
229+
Then open http://localhost:8080
230+
231+
---
232+
233+
### Deployment
234+
235+
Each student runs the workshop on their own laptop.
236+
237+
#### Using Python (venv)
238+
239+
**Windows:**
240+
```powershell
241+
python -m venv venv
242+
venv\Scripts\activate
243+
pip install -r requirements.txt
244+
python app.py
245+
```
246+
247+
**macOS/Linux:**
248+
```bash
249+
python3 -m venv venv
250+
source venv/bin/activate
251+
pip install -r requirements.txt
252+
python app.py
253+
```
254+
255+
#### Using Podman
256+
257+
**Windows (PowerShell):**
258+
```powershell
259+
podman machine start
260+
podman build -t python-workshop .
261+
podman run -p 5000:5000 python-workshop
262+
```
263+
264+
**macOS:**
265+
```bash
266+
podman machine start
267+
podman build -t python-workshop . && podman run -p 5000:5000 python-workshop
268+
```
269+
270+
**Linux:**
271+
```bash
272+
podman build -t python-workshop . && podman run -p 5000:5000 python-workshop
273+
```
274+
275+
Then open http://localhost:5000
276+
277+
---
278+
279+
### After Setup
280+
281+
1. Open your browser to: **http://127.0.0.1:5000**
282+
2. You'll see `(venv)` in your terminal when the virtual environment is active
283+
284+
### Deactivate Virtual Environment (when done)
285+
286+
```bash
287+
deactivate
288+
```
289+
290+
### Troubleshooting
291+
292+
| Problem | Solution |
293+
|---------|----------|
294+
| `python` not found | Try `python3` instead, or install Python from [python.org](https://python.org) |
295+
| `venv` not found | Install with `sudo apt install python3-venv` (Linux) |
296+
| PowerShell error | Run `Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser` |
297+
| Port 5000 in use | Use a different port: `podman run -p 8080:5000 python-workshop` or set `FLASK_PORT=5001` |
298+
| Podman not found | Install from [podman.io](https://podman.io/getting-started/installation) |
299+
| Container won't start | Check logs with `podman logs <container-name>` |
300+
301+
## Project Structure
302+
303+
```
304+
├── app.py # Flask application
305+
├── requirements.txt # Python dependencies
306+
├── Containerfile # Podman/Docker container definition
307+
├── .containerignore # Files to exclude from container
308+
├── templates/ # HTML templates
309+
│ ├── index.html # Home page
310+
│ ├── lesson.html # Lesson page
311+
│ └── reference.html # Quick reference
312+
└── static/
313+
├── style.css # Styles
314+
└── images/ # Images (logo, etc.)
315+
```
316+
317+
## Usage
318+
319+
1. Start at the home page to see all available lessons
320+
2. Click a lesson to begin learning
321+
3. Read the example code and explanations
322+
4. Click "Run Code" to execute and see output
323+
5. Modify the code and run again to experiment
324+
6. Try the exercises using the scratch pad
325+
7. Use hints if you get stuck

0 commit comments

Comments
 (0)