- Work Directory:
~/AI-Studio-ClearML - Bash Tip: When writing HTML via
echo, always use single quotes (') to wrap strings containing!. Using double quotes triggers a "bash: !DOCTYPE: event not found" error due to history expansion.
Run this to create a simple "Catch the Green Square" game: ```bash echo '<title>Terminal Game</title><style>body{text-align:center;font-family:sans-serif;background:#222;color:white}#game{width:400px;height:400px;border:2px solid #555;margin:20px auto;position:relative;background:#000;overflow:hidden}#player{width:30px;height:30px;background:#0f0;position:absolute;cursor:pointer;border-radius:4px}</style>
Score: 0
Start a Python server on port 8080: ```bash python3 -m http.server 8080 ```
There are two ways to view the file from another machine:
If you are logged into your AWS account on the other computer, use the SageMaker Proxy URL:
-
Base URL: To find and use the URL to view your HTML file, follow these steps:
-
Start the Space: You cannot access a URL until the instance is running. Click the Run space button (top left of your screenshot). Wait for the status to change from "Stopped" to Running. Once it's running, an Open JupyterLab button will appear. Click it.
-
Get the "Base" URL:when JupyterLab opens, look at your browser's address bar. It will look something like this: https://[unique-id].studio.[region].sagemaker.aws/jupyterlab/default/lab/...
-
Construct the "Proxy" URL: SageMaker uses a built-in proxy to let you view web servers (like the one you're trying to run). To see your index.html from another tab or computer: In your SageMaker Terminal, start your server:
The final URL should look like this: https://[unique-id].studio.[region].sagemaker.aws/jupyterlab/default/proxy/8080/index.html
-
- Access URL: Replace
/labwith/proxy/8080/game.html
- Access URL: Replace
-
To share with someone who doesn't have AWS access, use an SSH tunnel (localhost.run):
```bash
ssh -R 80:localhost:8080 nokey@localhost.run
```
Give the person the resulting https://...lhr.life link.