2.2 KiB
Spring Boot Banner Generator — Setup & Usage
Running the App
mvn spring-boot:run
The app starts on http://localhost:8080.
Web UI
Open your browser and go to:
http://localhost:8080/banner
Upload an image, choose light or dark mode, and the colored HTML banner is rendered in the page.
REST API
Generate a Banner
Endpoint: POST /api/banner
Content-Type: multipart/form-data
| Field | Type | Required | Description |
|---|---|---|---|
image |
file | yes | Image to convert (PNG, JPG, etc.) |
dark |
boolean | no | Use dark color scheme (default: false) |
Curl example:
curl -X POST http://localhost:8080/api/banner \
-F "image=@./logo.png" \
-F "dark=false"
Response (JSON):
{
"ansi": "${AnsiColor.RED}@@@@...",
"html": "<span style='color:#ff0000'>@</span>..."
}
Which Output to Use
ansi — Colored terminal banner for Spring Boot apps
The ansi field contains Spring Boot's ${AnsiColor.X} syntax. Paste it into src/main/resources/banner.txt in any Spring Boot project and it will print in color when the app starts.
Extract and save directly:
curl -s -X POST http://localhost:8080/api/banner \
-F "image=@./logo.png" \
-F "dark=false" \
| python -c "import sys,json; print(json.load(sys.stdin)['ansi'])" \
> /path/to/your-spring-app/src/main/resources/banner.txt
Then start your Spring Boot app — the banner prints in color in the terminal.
html — Colored banner for web pages
The html field contains inline <span style='color:#rrggbb'> tags. Drop it inside a <pre> tag in any HTML page:
<pre style="font-family: monospace; background: #000;">
<!-- paste html field value here -->
</pre>
Swagger UI
Interactive API docs are available at:
http://localhost:8080/swagger-ui.html
Use it to explore and test the /api/banner endpoint directly from the browser — upload a file, toggle dark mode, and see the live JSON response.
The raw OpenAPI spec (JSON) is at:
http://localhost:8080/v2/api-docs