Skip to content

Commit cf4767e

Browse files
authored
Merge pull request #10 from cloud-tinkerers/setup-brython
Added Brython sample and configured http.server
2 parents c5c8871 + 4d206ee commit cf4767e

File tree

5 files changed

+53
-9
lines changed

5 files changed

+53
-9
lines changed

.devcontainer/devcontainer.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
66
"image": "mcr.microsoft.com/devcontainers/base:jammy",
77
"features": {
8-
"ghcr.io/devcontainers/features/python:1": {},
8+
"ghcr.io/devcontainers/features/python:1": {
9+
"version": "3.11"
10+
},
911
"ghcr.io/devcontainers-contrib/features/black:2": {},
1012
"ghcr.io/devcontainers-contrib/features/coverage-py:2": {},
1113
"ghcr.io/devcontainers-contrib/features/mypy:2": {},
@@ -17,12 +19,15 @@
1719
},
1820
"customizations": {
1921
"extensions": [
20-
"ms-python.vscode-pylance",
22+
"ms-python.black-formatter",
23+
"ms-python.pylint",
2124
"ms-python.python",
25+
"ms-python.vscode-pylance",
2226
"alexcvzz.vscode-sqlite",
2327
"donjayamanne.python-extension-pack",
2428
"ms-python.black-formatter",
25-
"littlefoxteam.vscode-python-test-adapter"
29+
"littlefoxteam.vscode-python-test-adapter",
30+
"ms-vscode.azurecli"
2631
],
2732
},
2833
"mounts": [
@@ -34,8 +39,8 @@
3439

3540
// onstartcommand that installs lsd
3641
"postCreateCommand": "curl -L https://github.com/lsd-rs/lsd/releases/download/0.23.1/lsd_0.23.1_amd64.deb -o lsd_0.23.1_amd64.deb && dpkg -i lsd_0.23.1_amd64.deb && rm lsd_0.23.1_amd64.deb",
37-
"postStartCommand": "pip install --root-user-action=ignore -r requirements.txt",
42+
"postStartCommand": "pip install --root-user-action=ignore -r requirements.txt; python -m http.server 8080",
3843

3944
// Use 'forwardPorts' to make a list of ports inside the container available locally.
40-
// "forwardPorts": [],
45+
"forwardPorts": [8080],
4146
}

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
brython
1+
brython==3.11.2

src/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Configuring Brython and Getting Started with Python Puzzle Quest
2+
3+
Welcome to Python Puzzle Quest! This is a simple game built using Brython, a Python 3 implementation for client-side web programming.
4+
5+
## Getting Started
6+
7+
To get started with this project, you'll need to have Python 3 installed on your machine. You can download Python 3 from the official website: https://www.python.org/downloads/
8+
9+
Once you have Python 3 installed, you can run the game locally by following these steps:
10+
11+
1. Clone the repository to your local machine.
12+
2. Navigate to the `src` directory.
13+
3. Start a local web server by running the command `python -m http.server 8080` in your terminal.
14+
15+
```json
16+
"forwardPorts": [8080],
17+
```
18+
19+
4. Be sure to forward port 8080 in the devcontainer's `forwardPorts` attribute.
20+
5. Open your web browser and navigate to `http://localhost:8080`.
21+
22+
## How to Play
23+
24+
Once you have the game running in your web browser, you can use the arrow keys to move your character around the screen. Your goal is to collect as many coins as possible while avoiding the enemies. Good luck!
25+
26+
## Contributing
27+
28+
If you'd like to contribute to this project, please fork the repository and submit a pull request. We welcome contributions of all kinds, including bug fixes, new features, and documentation improvements.
29+
30+
## License
31+
32+
This project is licensed under the MIT License. See the `LICENSE` file for more information.

src/home/index.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<!DOCTYPE html>
22
<html>
3+
34
<head>
45
<title>Python Puzzle Quest</title>
56
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/brython/3.9.5/brython.min.js"></script>
@@ -10,18 +11,24 @@
1011
padding: 0;
1112
background-color: #f0f0f0;
1213
}
14+
1315
#content {
1416
margin: 20px;
1517
}
1618
</style>
1719
</head>
18-
<body onload="brython()">
20+
21+
<body onload="console.log('Brython is being loaded'); brython()">
1922
<div id="content">
2023
<h1>Welcome to Python Puzzle Quest!</h1>
2124
<p>Let's start with a simple Python code...</p>
25+
<button id="mybutton">Click me!</button>
26+
<script type="text/python3" src="../main.py"></script>
2227
<script type="text/python3">
23-
print("Hello, Python Puzzle Quest!")
28+
print("Hello world!")
2429
</script>
30+
2531
</div>
2632
</body>
33+
2734
</html>

src/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
def hello(event):
44
alert("Hello, Python Puzzle Quest!")
55

6-
document["mybutton"].bind("click", hello)
6+
document["mybutton"].bind("click", hello)

0 commit comments

Comments
 (0)