This is a program that generates ASCII art based on a given string and banner style specified. The program uses a web interface that is appealing, intuitive and user friendly to displays the results.
- Converts strings into ASCII art
- Supports numbers, letters, spaces, special characters, and newline characters ('\n')
- Utilizes specific graphical templates for ASCII representation
- Interactive web view: GUI (graphical user interface)
This program is written purely in Go language for the backend, before you think of running it, please make sure to have Go installed on your system.
-
Clone the repository:
git clone https://learn.zone01kisumu.ke/git/khahussein/ascii-art-web.git
-
Navigate to the project directory:
cd ascii-art-web-stylize/cmd/
Run the below command to start the server, then use the web browser to interact with the system localhost
go run .
Type something in the text area provided and should display some output
To test the functions, you can go two ways;
- Navigate to the tests directory and paste the following command.
go test -v
- Start the server with the above usage command and run the below command to test the program's functionality
curl -X POST -d "Text=Hello World&Banner=standard" http://localhost:8080/ascii-art
Expected Output:
_ _ _ _ __ __ _ _
| | | | | | | | \ \ / / | | | |
| |__| | ___ | | | | ___ \ \ /\ / / ___ _ __ | | __| |
| __ | / _ \ | | | | / _ \ \ \/ \/ / / _ \ | '__| | | / _` |
| | | | | __/ | | | | | (_) | \ /\ / | (_) | | | | | | (_| |
|_| |_| \___| |_| |_| \___/ \/ \/ \___/ |_| |_| \__,_|
Below is the function that handles requests and responses. This extract specifically displays the data based on the banner file selected and if the 'all' button is selected it displays data based on all the banner files.
func AsciiServer(w http.ResponseWriter, r *http.Request) {
// ...
all := []string{"standard", "thinkertoy", "shadow"}
if banner == "all" {
for i, bn := range all {
if i != 0 {
str += "\n"
}
str += writeAscii(w, bn, text)
}
} else {
str += writeAscii(w, banner, text)
}
// ...
fmt.Fprint(w, str)
}
standard.txt
: Standard ASCII character setshadow.txt
: Shadowed ASCII character setthinkertoy.txt
: ASCII character set with thinkertoy style
This program ensures file integrity using SHA-256 checksums. When downloading or verifying files (standard.txt, shadow.txt, thinkertoy.txt), it calculates the checksum of the downloaded file and compares it with a pre-defined expected checksum (expectedChecksum map). If the checksums do not match, it indicates that the file has been tampered with or corrupted.
If you have suggestions for improvements, bug fixes, or new features, feel free to open an issue or submit a pull request.
This project was build and maintained by: