Inspired by a salesperson who would always introduce me with a new title on every call
Enter this in the command line:
python3 titlecreator.py
or ./titlecreator.py
on Linux/BSD/macOS.
^ You did it! You have a new title! Add it to your Linkedin.
First, build the Docker image with the tag titlecreator:latest
:
docker build -t titlecreator:latest .
Run the container in CLI mode to get a single title printed to the console:
docker run --rm titlecreator:latest
Run the container with the web interface, accessible at http://localhost:8080:
docker run --rm -p 8080:8080 -e WEB_MODE=true titlecreator:latest
Then open your browser and visit http://localhost:8080
to see the interactive web interface with a "Generate Another Title" button.
The web service provides two ways to get JSON responses:
- Using the dedicated API endpoint:
curl http://localhost:8080/api/title
- Using the Accept header:
curl -H "Accept: application/json" http://localhost:8080/
Both will return a JSON response like:
{
"title": "AI Whisperer of Neural Networks",
"message": "Congratulations! Your new title is:"
}
This repository automatically builds and publishes Docker images to both GitHub Container Registry (GHCR) and Google Artifact Registry whenever changes are pushed to the main
branch.
- GitHub Container Registry:
ghcr.io/sntxrr/titlecreator:latest
- Google Artifact Registry:
us-west2-docker.pkg.dev/title-gen/titlegenerator/titlecreator:latest
# Using GHCR
docker run --rm ghcr.io/sntxrr/titlecreator:latest
# Using Google Artifact Registry (requires authentication)
docker run --rm us-west2-docker.pkg.dev/title-gen/titlegenerator/titlecreator:latest
# Using GHCR
docker run --rm -p 8080:8080 -e WEB_MODE=true ghcr.io/sntxrr/titlecreator:latest
# Using Google Artifact Registry (requires authentication)
docker run --rm -p 8080:8080 -e WEB_MODE=true us-west2-docker.pkg.dev/title-gen/titlegenerator/titlecreator:latest
Once the container is running, you can access the JSON API using either:
# Using the dedicated endpoint
curl http://localhost:8080/api/title
# Or using the Accept header
curl -H "Accept: application/json" http://localhost:8080/
- Install the Google Cloud SDK if you haven't already.
- Authenticate with Google Cloud:
gcloud auth login
If you're setting up your own instance, you can use the provided setup script:
PROJECT_ID=your-project-id ./setup-artifact-registry.sh
Note: If you see "ALREADY_EXISTS: the repository already exists", that's perfectly fine! It means the Artifact Registry is already configured and ready to use.
gcloud run deploy titlecreator \
--image us-west2-docker.pkg.dev/title-gen/titlegenerator/titlecreator:latest \
--platform managed \
--region us-west1 \
--allow-unauthenticated \
--set-env-vars WEB_MODE=true \
--project title-gen
gcloud run services replace cloudrun.yaml --region=us-west1 --project title-gen
After deployment, Cloud Run will provide you with a URL where your service is accessible.
Visit the provided URL in your browser to see the beautiful UI with the "Generate Another Title" button.
You can access the JSON API using:
# Using the dedicated endpoint
curl https://your-service-url/api/title
# Or using the Accept header
curl -H "Accept: application/json" https://your-service-url/
Both will return a JSON response like:
{
"title": "Supreme AI Whisperer of Neural Networks",
"message": "Congratulations! Your new title is:"
}
This repository is configured with GitHub Codespaces for instant development:
- Click
<> Code
βCreate codespace on main
- Pre-configured with Python, Docker, gcloud CLI, and all dependencies
- Port 8080 automatically forwarded for web testing
π Full Codespaces Documentation
# Install dependencies
pip install -r requirements.txt
# CLI mode
python TitleCreator.py
# Web mode
WEB_MODE=true python TitleCreator.py
python test_titlecreator.py
a golang
version