From 290c68795d8100cc97b8b53d80f331e536fc71b1 Mon Sep 17 00:00:00 2001 From: davidovski Date: Wed, 30 Nov 2022 10:06:56 +0000 Subject: Added files to repository --- src/webserver/dist/index.html | 122 ++++++++++++++++++ src/webserver/dist/map/afghanistan.png | Bin 0 -> 23211 bytes src/webserver/dist/map/albania.png | Bin 0 -> 6638 bytes src/webserver/dist/map/angolia.png | Bin 0 -> 27027 bytes src/webserver/dist/map/argentina.png | Bin 0 -> 34781 bytes src/webserver/dist/map/austria.png | Bin 0 -> 8881 bytes src/webserver/dist/map/azerbaijan.png | Bin 0 -> 22534 bytes src/webserver/dist/map/background.png | Bin 0 -> 685688 bytes src/webserver/dist/map/bangladesh.png | Bin 0 -> 7277 bytes src/webserver/dist/map/botswana.png | Bin 0 -> 24443 bytes src/webserver/dist/map/brazil.png | Bin 0 -> 42215 bytes src/webserver/dist/map/brunei.png | Bin 0 -> 6900 bytes src/webserver/dist/map/bulgaria.png | Bin 0 -> 22835 bytes src/webserver/dist/map/burundi.png | Bin 0 -> 7502 bytes src/webserver/dist/map/cambodia.png | Bin 0 -> 8653 bytes src/webserver/dist/map/cameroon.png | Bin 0 -> 25309 bytes src/webserver/dist/map/canada.png | Bin 0 -> 116756 bytes src/webserver/dist/map/chile.png | Bin 0 -> 19420 bytes src/webserver/dist/map/colombia.png | Bin 0 -> 26597 bytes src/webserver/dist/map/costa.png | Bin 0 -> 7024 bytes src/webserver/dist/map/croatia.png | Bin 0 -> 8524 bytes src/webserver/dist/map/cyprus.png | Bin 0 -> 8163 bytes src/webserver/dist/map/czech.png | Bin 0 -> 8929 bytes src/webserver/dist/map/denmark.png | Bin 0 -> 7671 bytes src/webserver/dist/map/dibouti.png | Bin 0 -> 7311 bytes src/webserver/dist/map/ecuador.png | Bin 0 -> 22644 bytes src/webserver/dist/map/estonia.png | Bin 0 -> 8392 bytes src/webserver/dist/map/ethopia.png | Bin 0 -> 26251 bytes src/webserver/dist/map/fiji.png | Bin 0 -> 6769 bytes src/webserver/dist/map/finland.png | Bin 0 -> 26057 bytes src/webserver/dist/map/haiti.png | Bin 0 -> 8111 bytes src/webserver/dist/map/honduras.png | Bin 0 -> 8963 bytes src/webserver/dist/map/hungary.png | Bin 0 -> 8481 bytes src/webserver/dist/map/iceland.png | Bin 0 -> 23212 bytes src/webserver/dist/map/india.png | Bin 0 -> 32085 bytes src/webserver/dist/map/indonesia.png | Bin 0 -> 36017 bytes src/webserver/dist/map/iran.png | Bin 0 -> 29620 bytes src/webserver/dist/map/ireland.png | Bin 0 -> 8956 bytes src/webserver/dist/map/israel.png | Bin 0 -> 7630 bytes src/webserver/dist/map/italy.png | Bin 0 -> 25329 bytes src/webserver/dist/map/jamaica.png | Bin 0 -> 7326 bytes src/webserver/dist/map/lithunia.png | Bin 0 -> 9185 bytes src/webserver/dist/map/luxemburj.png | Bin 0 -> 6768 bytes src/webserver/dist/map/macao.png | Bin 0 -> 6767 bytes src/webserver/dist/map/malaysia.png | Bin 0 -> 24856 bytes src/webserver/dist/map/malta.png | Bin 0 -> 6767 bytes src/webserver/dist/map/mauritius.png | Bin 0 -> 6768 bytes src/webserver/dist/map/mexico.png | Bin 0 -> 31649 bytes src/webserver/dist/map/moldova.png | Bin 0 -> 7755 bytes src/webserver/dist/map/namibia.png | Bin 0 -> 24016 bytes src/webserver/dist/map/netherland.png | Bin 0 -> 7973 bytes src/webserver/dist/map/nigeria.png | Bin 0 -> 24703 bytes src/webserver/dist/map/norway.png | Bin 0 -> 25462 bytes src/webserver/dist/map/panama.png | Bin 0 -> 8636 bytes src/webserver/dist/map/peru.png | Bin 0 -> 27826 bytes src/webserver/dist/map/philpine.png | Bin 0 -> 11118 bytes src/webserver/dist/map/poland.png | Bin 0 -> 24402 bytes src/webserver/dist/map/portugal.png | Bin 0 -> 8289 bytes src/webserver/dist/map/puerto_rico.png | Bin 0 -> 8158 bytes src/webserver/dist/map/russia.png | Bin 0 -> 98363 bytes src/webserver/dist/map/serbia.png | Bin 0 -> 22624 bytes src/webserver/dist/map/singapore.png | Bin 0 -> 7405 bytes src/webserver/dist/map/slovenia.png | Bin 0 -> 7381 bytes src/webserver/dist/map/south_africa.png | Bin 0 -> 28681 bytes src/webserver/dist/map/spain.png | Bin 0 -> 23987 bytes src/webserver/dist/map/sweden.png | Bin 0 -> 28746 bytes src/webserver/dist/map/switzerland.png | Bin 0 -> 8243 bytes src/webserver/dist/map/taiwan.png | Bin 0 -> 7412 bytes src/webserver/dist/map/uk.png | Bin 0 -> 25004 bytes src/webserver/dist/map/usa.png | Bin 0 -> 58284 bytes src/webserver/dist/site.js | 129 +++++++++++++++++++ src/webserver/dist/style.css | 138 +++++++++++++++++++++ src/webserver/dist/subdir/image.png | Bin 0 -> 226933 bytes src/webserver/dist/subdir/index.html | 1 + src/webserver/dist/subdir/test.txt | 1 + src/webserver/pom.xml | 47 +++++++ .../github/davidovski/names/APIRequestHandler.java | 112 +++++++++++++++++ .../davidovski/names/NameDatabaseManager.java | 75 +++++++++++ .../davidovski/names/StaticRequestHandler.java | 85 +++++++++++++ .../java/io/github/davidovski/names/WebServer.java | 51 ++++++++ 80 files changed, 761 insertions(+) create mode 100644 src/webserver/dist/index.html create mode 100644 src/webserver/dist/map/afghanistan.png create mode 100644 src/webserver/dist/map/albania.png create mode 100644 src/webserver/dist/map/angolia.png create mode 100644 src/webserver/dist/map/argentina.png create mode 100644 src/webserver/dist/map/austria.png create mode 100644 src/webserver/dist/map/azerbaijan.png create mode 100644 src/webserver/dist/map/background.png create mode 100644 src/webserver/dist/map/bangladesh.png create mode 100644 src/webserver/dist/map/botswana.png create mode 100644 src/webserver/dist/map/brazil.png create mode 100644 src/webserver/dist/map/brunei.png create mode 100644 src/webserver/dist/map/bulgaria.png create mode 100644 src/webserver/dist/map/burundi.png create mode 100644 src/webserver/dist/map/cambodia.png create mode 100644 src/webserver/dist/map/cameroon.png create mode 100644 src/webserver/dist/map/canada.png create mode 100644 src/webserver/dist/map/chile.png create mode 100644 src/webserver/dist/map/colombia.png create mode 100644 src/webserver/dist/map/costa.png create mode 100644 src/webserver/dist/map/croatia.png create mode 100644 src/webserver/dist/map/cyprus.png create mode 100644 src/webserver/dist/map/czech.png create mode 100644 src/webserver/dist/map/denmark.png create mode 100644 src/webserver/dist/map/dibouti.png create mode 100644 src/webserver/dist/map/ecuador.png create mode 100644 src/webserver/dist/map/estonia.png create mode 100644 src/webserver/dist/map/ethopia.png create mode 100644 src/webserver/dist/map/fiji.png create mode 100644 src/webserver/dist/map/finland.png create mode 100644 src/webserver/dist/map/haiti.png create mode 100644 src/webserver/dist/map/honduras.png create mode 100644 src/webserver/dist/map/hungary.png create mode 100644 src/webserver/dist/map/iceland.png create mode 100644 src/webserver/dist/map/india.png create mode 100644 src/webserver/dist/map/indonesia.png create mode 100644 src/webserver/dist/map/iran.png create mode 100644 src/webserver/dist/map/ireland.png create mode 100644 src/webserver/dist/map/israel.png create mode 100644 src/webserver/dist/map/italy.png create mode 100644 src/webserver/dist/map/jamaica.png create mode 100644 src/webserver/dist/map/lithunia.png create mode 100644 src/webserver/dist/map/luxemburj.png create mode 100644 src/webserver/dist/map/macao.png create mode 100644 src/webserver/dist/map/malaysia.png create mode 100644 src/webserver/dist/map/malta.png create mode 100644 src/webserver/dist/map/mauritius.png create mode 100644 src/webserver/dist/map/mexico.png create mode 100644 src/webserver/dist/map/moldova.png create mode 100644 src/webserver/dist/map/namibia.png create mode 100644 src/webserver/dist/map/netherland.png create mode 100644 src/webserver/dist/map/nigeria.png create mode 100644 src/webserver/dist/map/norway.png create mode 100644 src/webserver/dist/map/panama.png create mode 100644 src/webserver/dist/map/peru.png create mode 100644 src/webserver/dist/map/philpine.png create mode 100644 src/webserver/dist/map/poland.png create mode 100644 src/webserver/dist/map/portugal.png create mode 100644 src/webserver/dist/map/puerto_rico.png create mode 100644 src/webserver/dist/map/russia.png create mode 100644 src/webserver/dist/map/serbia.png create mode 100644 src/webserver/dist/map/singapore.png create mode 100644 src/webserver/dist/map/slovenia.png create mode 100644 src/webserver/dist/map/south_africa.png create mode 100644 src/webserver/dist/map/spain.png create mode 100644 src/webserver/dist/map/sweden.png create mode 100644 src/webserver/dist/map/switzerland.png create mode 100644 src/webserver/dist/map/taiwan.png create mode 100644 src/webserver/dist/map/uk.png create mode 100644 src/webserver/dist/map/usa.png create mode 100644 src/webserver/dist/site.js create mode 100644 src/webserver/dist/style.css create mode 100644 src/webserver/dist/subdir/image.png create mode 100644 src/webserver/dist/subdir/index.html create mode 100644 src/webserver/dist/subdir/test.txt create mode 100644 src/webserver/pom.xml create mode 100644 src/webserver/src/main/java/io/github/davidovski/names/APIRequestHandler.java create mode 100644 src/webserver/src/main/java/io/github/davidovski/names/NameDatabaseManager.java create mode 100644 src/webserver/src/main/java/io/github/davidovski/names/StaticRequestHandler.java create mode 100644 src/webserver/src/main/java/io/github/davidovski/names/WebServer.java (limited to 'src/webserver') diff --git a/src/webserver/dist/index.html b/src/webserver/dist/index.html new file mode 100644 index 0000000..cd016b2 --- /dev/null +++ b/src/webserver/dist/index.html @@ -0,0 +1,122 @@ + + + + + Name Generator + + + + + + + + + +
+

Name Generator

+ +
+ +
+ + + +
+ + + +
+ + + + +
+ +
+ + +
+ + + + diff --git a/src/webserver/dist/map/afghanistan.png b/src/webserver/dist/map/afghanistan.png new file mode 100644 index 0000000..49abc92 Binary files /dev/null and b/src/webserver/dist/map/afghanistan.png differ diff --git a/src/webserver/dist/map/albania.png b/src/webserver/dist/map/albania.png new file mode 100644 index 0000000..c045c57 Binary files /dev/null and b/src/webserver/dist/map/albania.png differ diff --git a/src/webserver/dist/map/angolia.png b/src/webserver/dist/map/angolia.png new file mode 100644 index 0000000..2e415e5 Binary files /dev/null and b/src/webserver/dist/map/angolia.png differ diff --git a/src/webserver/dist/map/argentina.png b/src/webserver/dist/map/argentina.png new file mode 100644 index 0000000..458376c Binary files /dev/null and b/src/webserver/dist/map/argentina.png differ diff --git a/src/webserver/dist/map/austria.png b/src/webserver/dist/map/austria.png new file mode 100644 index 0000000..f3ed00e Binary files /dev/null and b/src/webserver/dist/map/austria.png differ diff --git a/src/webserver/dist/map/azerbaijan.png b/src/webserver/dist/map/azerbaijan.png new file mode 100644 index 0000000..430b9d6 Binary files /dev/null and b/src/webserver/dist/map/azerbaijan.png differ diff --git a/src/webserver/dist/map/background.png b/src/webserver/dist/map/background.png new file mode 100644 index 0000000..77802f6 Binary files /dev/null and b/src/webserver/dist/map/background.png differ diff --git a/src/webserver/dist/map/bangladesh.png b/src/webserver/dist/map/bangladesh.png new file mode 100644 index 0000000..8fdf65a Binary files /dev/null and b/src/webserver/dist/map/bangladesh.png differ diff --git a/src/webserver/dist/map/botswana.png b/src/webserver/dist/map/botswana.png new file mode 100644 index 0000000..ec58775 Binary files /dev/null and b/src/webserver/dist/map/botswana.png differ diff --git a/src/webserver/dist/map/brazil.png b/src/webserver/dist/map/brazil.png new file mode 100644 index 0000000..8ba32c5 Binary files /dev/null and b/src/webserver/dist/map/brazil.png differ diff --git a/src/webserver/dist/map/brunei.png b/src/webserver/dist/map/brunei.png new file mode 100644 index 0000000..c518380 Binary files /dev/null and b/src/webserver/dist/map/brunei.png differ diff --git a/src/webserver/dist/map/bulgaria.png b/src/webserver/dist/map/bulgaria.png new file mode 100644 index 0000000..c8edece Binary files /dev/null and b/src/webserver/dist/map/bulgaria.png differ diff --git a/src/webserver/dist/map/burundi.png b/src/webserver/dist/map/burundi.png new file mode 100644 index 0000000..3f8d894 Binary files /dev/null and b/src/webserver/dist/map/burundi.png differ diff --git a/src/webserver/dist/map/cambodia.png b/src/webserver/dist/map/cambodia.png new file mode 100644 index 0000000..c92c6f3 Binary files /dev/null and b/src/webserver/dist/map/cambodia.png differ diff --git a/src/webserver/dist/map/cameroon.png b/src/webserver/dist/map/cameroon.png new file mode 100644 index 0000000..b5b57ea Binary files /dev/null and b/src/webserver/dist/map/cameroon.png differ diff --git a/src/webserver/dist/map/canada.png b/src/webserver/dist/map/canada.png new file mode 100644 index 0000000..7358637 Binary files /dev/null and b/src/webserver/dist/map/canada.png differ diff --git a/src/webserver/dist/map/chile.png b/src/webserver/dist/map/chile.png new file mode 100644 index 0000000..e0a3c50 Binary files /dev/null and b/src/webserver/dist/map/chile.png differ diff --git a/src/webserver/dist/map/colombia.png b/src/webserver/dist/map/colombia.png new file mode 100644 index 0000000..3859cc0 Binary files /dev/null and b/src/webserver/dist/map/colombia.png differ diff --git a/src/webserver/dist/map/costa.png b/src/webserver/dist/map/costa.png new file mode 100644 index 0000000..035badd Binary files /dev/null and b/src/webserver/dist/map/costa.png differ diff --git a/src/webserver/dist/map/croatia.png b/src/webserver/dist/map/croatia.png new file mode 100644 index 0000000..1ce5650 Binary files /dev/null and b/src/webserver/dist/map/croatia.png differ diff --git a/src/webserver/dist/map/cyprus.png b/src/webserver/dist/map/cyprus.png new file mode 100644 index 0000000..ea90e2a Binary files /dev/null and b/src/webserver/dist/map/cyprus.png differ diff --git a/src/webserver/dist/map/czech.png b/src/webserver/dist/map/czech.png new file mode 100644 index 0000000..9f89545 Binary files /dev/null and b/src/webserver/dist/map/czech.png differ diff --git a/src/webserver/dist/map/denmark.png b/src/webserver/dist/map/denmark.png new file mode 100644 index 0000000..bef926b Binary files /dev/null and b/src/webserver/dist/map/denmark.png differ diff --git a/src/webserver/dist/map/dibouti.png b/src/webserver/dist/map/dibouti.png new file mode 100644 index 0000000..43015e8 Binary files /dev/null and b/src/webserver/dist/map/dibouti.png differ diff --git a/src/webserver/dist/map/ecuador.png b/src/webserver/dist/map/ecuador.png new file mode 100644 index 0000000..bf2e9d4 Binary files /dev/null and b/src/webserver/dist/map/ecuador.png differ diff --git a/src/webserver/dist/map/estonia.png b/src/webserver/dist/map/estonia.png new file mode 100644 index 0000000..fa6ac33 Binary files /dev/null and b/src/webserver/dist/map/estonia.png differ diff --git a/src/webserver/dist/map/ethopia.png b/src/webserver/dist/map/ethopia.png new file mode 100644 index 0000000..207b3e7 Binary files /dev/null and b/src/webserver/dist/map/ethopia.png differ diff --git a/src/webserver/dist/map/fiji.png b/src/webserver/dist/map/fiji.png new file mode 100644 index 0000000..b574fc9 Binary files /dev/null and b/src/webserver/dist/map/fiji.png differ diff --git a/src/webserver/dist/map/finland.png b/src/webserver/dist/map/finland.png new file mode 100644 index 0000000..1a2754e Binary files /dev/null and b/src/webserver/dist/map/finland.png differ diff --git a/src/webserver/dist/map/haiti.png b/src/webserver/dist/map/haiti.png new file mode 100644 index 0000000..c0773a6 Binary files /dev/null and b/src/webserver/dist/map/haiti.png differ diff --git a/src/webserver/dist/map/honduras.png b/src/webserver/dist/map/honduras.png new file mode 100644 index 0000000..fa7442d Binary files /dev/null and b/src/webserver/dist/map/honduras.png differ diff --git a/src/webserver/dist/map/hungary.png b/src/webserver/dist/map/hungary.png new file mode 100644 index 0000000..97d9e91 Binary files /dev/null and b/src/webserver/dist/map/hungary.png differ diff --git a/src/webserver/dist/map/iceland.png b/src/webserver/dist/map/iceland.png new file mode 100644 index 0000000..d1f0e7d Binary files /dev/null and b/src/webserver/dist/map/iceland.png differ diff --git a/src/webserver/dist/map/india.png b/src/webserver/dist/map/india.png new file mode 100644 index 0000000..e0fc17b Binary files /dev/null and b/src/webserver/dist/map/india.png differ diff --git a/src/webserver/dist/map/indonesia.png b/src/webserver/dist/map/indonesia.png new file mode 100644 index 0000000..c31bf40 Binary files /dev/null and b/src/webserver/dist/map/indonesia.png differ diff --git a/src/webserver/dist/map/iran.png b/src/webserver/dist/map/iran.png new file mode 100644 index 0000000..2ee5b2b Binary files /dev/null and b/src/webserver/dist/map/iran.png differ diff --git a/src/webserver/dist/map/ireland.png b/src/webserver/dist/map/ireland.png new file mode 100644 index 0000000..92fd6dc Binary files /dev/null and b/src/webserver/dist/map/ireland.png differ diff --git a/src/webserver/dist/map/israel.png b/src/webserver/dist/map/israel.png new file mode 100644 index 0000000..3c350f2 Binary files /dev/null and b/src/webserver/dist/map/israel.png differ diff --git a/src/webserver/dist/map/italy.png b/src/webserver/dist/map/italy.png new file mode 100644 index 0000000..fb18140 Binary files /dev/null and b/src/webserver/dist/map/italy.png differ diff --git a/src/webserver/dist/map/jamaica.png b/src/webserver/dist/map/jamaica.png new file mode 100644 index 0000000..0cc2224 Binary files /dev/null and b/src/webserver/dist/map/jamaica.png differ diff --git a/src/webserver/dist/map/lithunia.png b/src/webserver/dist/map/lithunia.png new file mode 100644 index 0000000..633fc4b Binary files /dev/null and b/src/webserver/dist/map/lithunia.png differ diff --git a/src/webserver/dist/map/luxemburj.png b/src/webserver/dist/map/luxemburj.png new file mode 100644 index 0000000..c296bd0 Binary files /dev/null and b/src/webserver/dist/map/luxemburj.png differ diff --git a/src/webserver/dist/map/macao.png b/src/webserver/dist/map/macao.png new file mode 100644 index 0000000..8c3017b Binary files /dev/null and b/src/webserver/dist/map/macao.png differ diff --git a/src/webserver/dist/map/malaysia.png b/src/webserver/dist/map/malaysia.png new file mode 100644 index 0000000..7c14b5a Binary files /dev/null and b/src/webserver/dist/map/malaysia.png differ diff --git a/src/webserver/dist/map/malta.png b/src/webserver/dist/map/malta.png new file mode 100644 index 0000000..bdbfc49 Binary files /dev/null and b/src/webserver/dist/map/malta.png differ diff --git a/src/webserver/dist/map/mauritius.png b/src/webserver/dist/map/mauritius.png new file mode 100644 index 0000000..6e39be8 Binary files /dev/null and b/src/webserver/dist/map/mauritius.png differ diff --git a/src/webserver/dist/map/mexico.png b/src/webserver/dist/map/mexico.png new file mode 100644 index 0000000..ac7d570 Binary files /dev/null and b/src/webserver/dist/map/mexico.png differ diff --git a/src/webserver/dist/map/moldova.png b/src/webserver/dist/map/moldova.png new file mode 100644 index 0000000..aea9bb2 Binary files /dev/null and b/src/webserver/dist/map/moldova.png differ diff --git a/src/webserver/dist/map/namibia.png b/src/webserver/dist/map/namibia.png new file mode 100644 index 0000000..013eb0c Binary files /dev/null and b/src/webserver/dist/map/namibia.png differ diff --git a/src/webserver/dist/map/netherland.png b/src/webserver/dist/map/netherland.png new file mode 100644 index 0000000..ea929f8 Binary files /dev/null and b/src/webserver/dist/map/netherland.png differ diff --git a/src/webserver/dist/map/nigeria.png b/src/webserver/dist/map/nigeria.png new file mode 100644 index 0000000..fbb8c81 Binary files /dev/null and b/src/webserver/dist/map/nigeria.png differ diff --git a/src/webserver/dist/map/norway.png b/src/webserver/dist/map/norway.png new file mode 100644 index 0000000..8246c98 Binary files /dev/null and b/src/webserver/dist/map/norway.png differ diff --git a/src/webserver/dist/map/panama.png b/src/webserver/dist/map/panama.png new file mode 100644 index 0000000..2a080cb Binary files /dev/null and b/src/webserver/dist/map/panama.png differ diff --git a/src/webserver/dist/map/peru.png b/src/webserver/dist/map/peru.png new file mode 100644 index 0000000..c0c759b Binary files /dev/null and b/src/webserver/dist/map/peru.png differ diff --git a/src/webserver/dist/map/philpine.png b/src/webserver/dist/map/philpine.png new file mode 100644 index 0000000..4301c70 Binary files /dev/null and b/src/webserver/dist/map/philpine.png differ diff --git a/src/webserver/dist/map/poland.png b/src/webserver/dist/map/poland.png new file mode 100644 index 0000000..f16d57f Binary files /dev/null and b/src/webserver/dist/map/poland.png differ diff --git a/src/webserver/dist/map/portugal.png b/src/webserver/dist/map/portugal.png new file mode 100644 index 0000000..bdec23d Binary files /dev/null and b/src/webserver/dist/map/portugal.png differ diff --git a/src/webserver/dist/map/puerto_rico.png b/src/webserver/dist/map/puerto_rico.png new file mode 100644 index 0000000..e7c0b10 Binary files /dev/null and b/src/webserver/dist/map/puerto_rico.png differ diff --git a/src/webserver/dist/map/russia.png b/src/webserver/dist/map/russia.png new file mode 100644 index 0000000..e77b48f Binary files /dev/null and b/src/webserver/dist/map/russia.png differ diff --git a/src/webserver/dist/map/serbia.png b/src/webserver/dist/map/serbia.png new file mode 100644 index 0000000..c3debe2 Binary files /dev/null and b/src/webserver/dist/map/serbia.png differ diff --git a/src/webserver/dist/map/singapore.png b/src/webserver/dist/map/singapore.png new file mode 100644 index 0000000..59e3aec Binary files /dev/null and b/src/webserver/dist/map/singapore.png differ diff --git a/src/webserver/dist/map/slovenia.png b/src/webserver/dist/map/slovenia.png new file mode 100644 index 0000000..1dd5ebf Binary files /dev/null and b/src/webserver/dist/map/slovenia.png differ diff --git a/src/webserver/dist/map/south_africa.png b/src/webserver/dist/map/south_africa.png new file mode 100644 index 0000000..ecdccb7 Binary files /dev/null and b/src/webserver/dist/map/south_africa.png differ diff --git a/src/webserver/dist/map/spain.png b/src/webserver/dist/map/spain.png new file mode 100644 index 0000000..b6947e3 Binary files /dev/null and b/src/webserver/dist/map/spain.png differ diff --git a/src/webserver/dist/map/sweden.png b/src/webserver/dist/map/sweden.png new file mode 100644 index 0000000..6b7ba10 Binary files /dev/null and b/src/webserver/dist/map/sweden.png differ diff --git a/src/webserver/dist/map/switzerland.png b/src/webserver/dist/map/switzerland.png new file mode 100644 index 0000000..6a8180a Binary files /dev/null and b/src/webserver/dist/map/switzerland.png differ diff --git a/src/webserver/dist/map/taiwan.png b/src/webserver/dist/map/taiwan.png new file mode 100644 index 0000000..ca08390 Binary files /dev/null and b/src/webserver/dist/map/taiwan.png differ diff --git a/src/webserver/dist/map/uk.png b/src/webserver/dist/map/uk.png new file mode 100644 index 0000000..51f6e4d Binary files /dev/null and b/src/webserver/dist/map/uk.png differ diff --git a/src/webserver/dist/map/usa.png b/src/webserver/dist/map/usa.png new file mode 100644 index 0000000..06cabde Binary files /dev/null and b/src/webserver/dist/map/usa.png differ diff --git a/src/webserver/dist/site.js b/src/webserver/dist/site.js new file mode 100644 index 0000000..2e9bac3 --- /dev/null +++ b/src/webserver/dist/site.js @@ -0,0 +1,129 @@ + + +// the function to be called when the generate name button is pressed +function generateName() { + + // get the values of the various buttons and selectors and store them as variables + var gender = document.getElementById("gender").value; + var origin = document.getElementById("origin").value; + + var count = parseInt(document.getElementById("number").value); + var surnames = document.getElementById("surnames").checked; + + // create a request object + var request = { + "origin": origin, + "gender": gender, + "count": count, + "surname": surnames + }; + + // turn the request json into a string + request = JSON.stringify(request) + + console.log(request) + + // Make the http request using ajax + const http = new XMLHttpRequest(); + const url = "/api/name"; + http.open("POST", url); + http.send(request); + + // create a listener for when the request is returned + http.onreadystatechange = (e) => { + showNames(JSON.parse(http.responseText)) + } +} + +// Change the page's html to show the generated names +function showNames(names) { + + // get the name area element + var nameArea = document.getElementById("namearea"); + + // delete all existing name entries + while (nameArea.lastChild) { + nameArea.removeChild(nameArea.lastChild); + } + + // iterate through all of the given names + names.names.forEach((name) => { + + // create the name element + var nameElement = document.createElement("p"); + nameElement.textContent = name; + nameElement.classList.add("name"); + + // add the name element to the name area + nameArea.appendChild(nameElement); + }); +} + +function updateMap() { + // Load the current country of origin + var origin = document.getElementById("origin").value; + + console.log(origin) + + // get the canvas context for the worldmap + var canvas = document.getElementById("worldmap"); + var context = canvas.getContext("2d"); + + // clear the canvas + context.clearRect(0, 0, canvas.width, canvas.height); + + // create the background image + var background = new Image(); + background.src = "/map/background.png" + + // wait for the image to load before trying to draw it + background.onload = function() { + context.drawImage(background, 0, 0) + + // only draw the country after the background has been drawn + var country = new Image(); + country.src = "/map/" + origin + ".png" + + // wait for the image to load before trying to draw it + country.onload = function() { + context.drawImage(country, 0, 0) + }; + + }; + +} + +// force the count to be between 1 and 99 +function forceCount() { + var count = parseInt(document.getElementById("number").value); + if (count > 99) { + document.getElementById("number").value = 99 + } else if (count < 1) { + document.getElementById("number").value = 1 + } +} + +// toggle the visibility of advanced options +function toggleAdvanced() { + // get the advanced options div + var element = document.getElementById("advancedoptions"); + + // if display: none, make it visible and vice versa + if (element.style.display == "none") { + element.style.display = "" + } else { + element.style.display = "none" + } + +} + +// toggle the checkbox from checked to unchecked and vice versa +function checkBox(checkbox) { + if (checkbox.getAttribute("checked")) { + // uncheck the box + checkbox.removeAttribute("checked"); + } else { + // set the box to checked + checkbox.setAttribute("checked", true); + } +} diff --git a/src/webserver/dist/style.css b/src/webserver/dist/style.css new file mode 100644 index 0000000..1ba596d --- /dev/null +++ b/src/webserver/dist/style.css @@ -0,0 +1,138 @@ +#worldmap { + width: 50%; +} + +body { + font-family: sans-serif; + background-color: #191919; + color: #f0c674; + width:auto; +} + +.main { + padding: 0; + margin-left: 10%; + margin-right: 10%; + width: 80%; + font-size: 2rem; +} + +#worldmap { + width: 50%; +} + +@media (orientation : portrait) { + .main { + padding: 0; + margin: 0; + width: 100%; + font-size: 1.5rem; + } + + #worldmap { + width: 100%; + } +} + + +.main { + display: inline-block; + text-align: center; + +} + +.box-item { + margin-top: 1rem; + margin-bottom: 1rem; +} + + +button,select,input[type=number] { + font-size: inherit; + background-color: #191919; + color: #f0c674; + border-radius: 0.5em; + text-decoration: none; + padding: 0.5rem; + border: 0.05rem solid #373b41; + box-shadow: 0 0.2em #373b41; +} + +#number { + width: 3rem; +} +img { + width: 2rem; +} + +button:active { + background-color: #373b41; + box-shadow: 0 0.1em #373b41; + transform: translateY(0.1em); +} + + +.box { + margin-top: 10%; + padding: 1%; + text-align: center; + display: inline-block; + box-sizing: border-box; + margin-left:15%; + width: 70%; + height: 50%; + + background: transparent; + border: 0; + outline: 0; + border-bottom: 0.25rem solid #0f7d7b; + color: #e8922a; + font-size: 100%; + outline: none !important; + +} +input:focus, textarea { + outline: none !important; +} +button:focus, textarea { + outline: none !important; +} + + +input[type=checkbox]{ + position:absolute; + opacity: 0; + z-index: -9999; +} + +input[type=checkbox] + .indicator { + width: 1.5rem; + height: 1.5rem; + margin-left: 0.5rem; + position: absolute; + + + font-size: inherit; + background-color: #191919; + color: #191919; + border-radius: 0.5em; + text-decoration: none; + padding: 0.5rem; + border: 0.05rem solid #373b41; + box-shadow: 0 0.2em #373b41; + + content: ""; +} + +input[type=checkbox]:checked + .indicator { + background-color: #373b41; + box-shadow: 0 0.1em #373b41; + transform: translateY(0.1em); +} + +input[type=checkbox]+ .indicator::after { + content: ""; +} +input[type=checkbox]:checked + .indicator::after { + content: "X"; +} diff --git a/src/webserver/dist/subdir/image.png b/src/webserver/dist/subdir/image.png new file mode 100644 index 0000000..80fb972 Binary files /dev/null and b/src/webserver/dist/subdir/image.png differ diff --git a/src/webserver/dist/subdir/index.html b/src/webserver/dist/subdir/index.html new file mode 100644 index 0000000..b7e784a --- /dev/null +++ b/src/webserver/dist/subdir/index.html @@ -0,0 +1 @@ +index of the sub dir diff --git a/src/webserver/dist/subdir/test.txt b/src/webserver/dist/subdir/test.txt new file mode 100644 index 0000000..6ee329a --- /dev/null +++ b/src/webserver/dist/subdir/test.txt @@ -0,0 +1 @@ +this is text.txt diff --git a/src/webserver/pom.xml b/src/webserver/pom.xml new file mode 100644 index 0000000..c4a716d --- /dev/null +++ b/src/webserver/pom.xml @@ -0,0 +1,47 @@ + + 4.0.0 + io.github.davidovski.names + NameGenerator + 0.0.1-SNAPSHOT + jar + + + org.xerial + sqlite-jdbc + 3.32.3 + + + org.json + json + 20210307 + + + + + + + org.apache.maven.plugins + maven-shade-plugin + + + + shade + + + true + + + io.github.davidovski.names.WebServer + + + + + + + + + + diff --git a/src/webserver/src/main/java/io/github/davidovski/names/APIRequestHandler.java b/src/webserver/src/main/java/io/github/davidovski/names/APIRequestHandler.java new file mode 100644 index 0000000..5ef2cfe --- /dev/null +++ b/src/webserver/src/main/java/io/github/davidovski/names/APIRequestHandler.java @@ -0,0 +1,112 @@ +package io.github.davidovski.names; + +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.util.List; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.json.JSONTokener; + +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpHandler; + +@SuppressWarnings("restriction") +public class APIRequestHandler implements HttpHandler { + + private NameDatabaseManager nameDatabaseManager; + + public APIRequestHandler() { + nameDatabaseManager = new NameDatabaseManager(new File("names.db")); + } + + @Override + public void handle(HttpExchange exchange) throws IOException { + // get the requested path + String path = exchange.getRequestURI().getPath(); + + System.out.println(path); + + if (path.startsWith("/api/name")) { + + // parse the body as a json object + JSONTokener jsonParser = new JSONTokener(exchange.getRequestBody()); + JSONObject json = (JSONObject) jsonParser.nextValue(); + + System.out.println(json.toString(2)); + + if (json == null) { + // Malformed JSON request, 400 + sendJSON(exchange, (new JSONObject()).put("message", "Malformed JSON body"), 400); + return; + } + + // generate name(s) and send it + generateName(exchange, json); + } else { + sendJSON(exchange, (new JSONObject()).put("message", "Not Found"), 404); + } + } + + public void generateName(HttpExchange exchange, JSONObject options) throws JSONException, IOException { + String origin = options.optString("origin", "none").toLowerCase(); + + int count = options.optInt("count", 1); + + // ensure that the count is between 1-100 + if (count < 1 || count > 100) { + sendJSON(exchange, (new JSONObject()).put("message", "Name count is out of range: Ensure that the request is between 1 and 100 names"), 400); + return; + } + + String gender = options.optString("gender", "female"); + + // ensure that the gender is either male or female + if (!gender.equals("male") && !gender.equals("female")) { + sendJSON(exchange, (new JSONObject()).put("message", "Requested gender is invalid"), 400); + return; + } + + // Store the names in an array + List names = nameDatabaseManager.getRandomNames(origin, gender, count); + + if (options.optBoolean("surname")) { + List surnames = nameDatabaseManager.getRandomNames(origin, "surname", count); + + // Add surnames to the end of each firstname in the names list + for (int i = 0; i < count; i++) { + String fullname = names.get(i) + " " + surnames.get(i); + names.set(i, fullname); + } + } + + // Create the response json object + JSONObject response = new JSONObject(); + response.put("message", "Generated " + count + " names"); + response.put("names", new JSONArray(names)); + + // send the json back to the client + sendJSON(exchange, response, 200); + } + + public void sendJSON(HttpExchange exchange, JSONObject json, int responseCode) throws IOException { + // convert the json to a string + String response = json.toString(2); + + // calculate the response content size + int contentSize = response.toString().getBytes().length; + + // set the response headers + exchange.getResponseHeaders().add("Content-Type", "text/json"); + exchange.sendResponseHeaders(responseCode, contentSize); + + // write the response to the output stream + OutputStream outputStream = exchange.getResponseBody(); + + outputStream.write(response.toString().getBytes()); + outputStream.close(); + } + +} diff --git a/src/webserver/src/main/java/io/github/davidovski/names/NameDatabaseManager.java b/src/webserver/src/main/java/io/github/davidovski/names/NameDatabaseManager.java new file mode 100644 index 0000000..8822d9c --- /dev/null +++ b/src/webserver/src/main/java/io/github/davidovski/names/NameDatabaseManager.java @@ -0,0 +1,75 @@ +package io.github.davidovski.names; + +import java.io.File; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +public class NameDatabaseManager { + private File databaseFile; + private Connection connection; + + private static final String TABLE = "names"; + + public NameDatabaseManager(File databaseFile) { + this.databaseFile = databaseFile; + + connect(); + } + + /** + * Creates a connection to the database. If one could not be created, the connection will remain as null + */ + private void connect() { + connection = null; + try { + connection = DriverManager.getConnection("jdbc:sqlite:" + databaseFile.getPath()); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + public List getRandomNames(String origin, String category, int quantitiy) { + // create the set to return, even if empty + List names = new ArrayList(); + + if (connection != null) { + // Create an sql statement + String sql = "SELECT Name FROM " + TABLE + " WHERE Origin=? AND Category=? ORDER BY RANDOM() LIMIT ?;"; + PreparedStatement statement; + try { + statement = connection.prepareStatement(sql); + + // insert relevant values into the statement + statement.setString(1, origin); + statement.setString(2, category); + statement.setInt(3, quantitiy); + + // execute the query and get the result + ResultSet result = statement.executeQuery(); + + // Add all of the results to the names set + while (result.next()) { + String name = result.getString("Name"); + names.add(name); + } + } catch (SQLException e) { + e.printStackTrace(); + } + + } + return names; + } + + public static void main(String[] args) { + NameDatabaseManager dbManager = new NameDatabaseManager(new File("names.db")); + List names = dbManager.getRandomNames("spain", "female", 10); + for (String name : names) { + System.out.println(name); + } + } +} diff --git a/src/webserver/src/main/java/io/github/davidovski/names/StaticRequestHandler.java b/src/webserver/src/main/java/io/github/davidovski/names/StaticRequestHandler.java new file mode 100644 index 0000000..d10d0b1 --- /dev/null +++ b/src/webserver/src/main/java/io/github/davidovski/names/StaticRequestHandler.java @@ -0,0 +1,85 @@ +package io.github.davidovski.names; + +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.nio.file.Files; + +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpHandler; + +@SuppressWarnings("restriction") +public class StaticRequestHandler implements HttpHandler { + private File root; + + public StaticRequestHandler(File root) { + this.root = root; + } + + @Override + public void handle(HttpExchange exchange) throws IOException { + // get the requested path + String path = exchange.getRequestURI().getPath(); + + File requested = new File(root, path); + + // automatically send the index of a directory + if (requested.isDirectory()) { + requested = new File(requested, "index.html"); + } + + // ensure that the file is in the intended document root + if (!isInRoot(requested, root)) { + sendText(exchange, "Access Denied", 403); + } else if (requested.exists()) { + sendFile(exchange, requested); + } else { + // send 404 if the file isnt found + sendText(exchange, "File Not Found", 404); + } + } + + private void sendFile(HttpExchange exchange, File file) throws IOException { + // read the file as into an array of bytes + byte[] bytes = Files.readAllBytes(file.toPath()); + + // send the file headers + exchange.sendResponseHeaders(200, bytes.length); + + // send the file body + OutputStream os = exchange.getResponseBody(); + os.write(bytes); + os.close(); + } + + private void sendText(HttpExchange exchange, String response, int responseCode) throws IOException { + // calculate the response content size + int contentSize = response.toString().getBytes().length; + + // set the response headers + exchange.getResponseHeaders().add("Content-Type", "text/json"); + exchange.sendResponseHeaders(responseCode, contentSize); + + // write the response to the output stream + OutputStream outputStream = exchange.getResponseBody(); + + outputStream.write(response.toString().getBytes()); + outputStream.close(); + } + + public static boolean isInRoot(File request, File root) { + File parentFile = request; + + // start from the requested file and traverse upwards until reaching the root directory + while (parentFile != null) { + if (root.equals(parentFile)) { + return true; + } + parentFile = parentFile.getParentFile(); + } + + // If there isn't a parent file, return false + return false; + } + +} diff --git a/src/webserver/src/main/java/io/github/davidovski/names/WebServer.java b/src/webserver/src/main/java/io/github/davidovski/names/WebServer.java new file mode 100644 index 0000000..60b311f --- /dev/null +++ b/src/webserver/src/main/java/io/github/davidovski/names/WebServer.java @@ -0,0 +1,51 @@ +package io.github.davidovski.names; + +import java.io.File; +import java.io.IOException; +import java.net.InetSocketAddress; + +import com.sun.net.httpserver.HttpServer; + +@SuppressWarnings("restriction") +public class WebServer { + private int port; + private HttpServer server; + + public WebServer(int port) throws IOException { + this.port = port; + + // create an HTTP server instance + InetSocketAddress socketAddress = new InetSocketAddress(port); + server = HttpServer.create(socketAddress, 0); + + // create a context for the static request handler + server.createContext("/", new StaticRequestHandler(new File("dist"))); + // create a context for the api request handler + server.createContext("/api", new APIRequestHandler()); + + } + + public void start() { + server.start(); + + // tell the user that the webserver has been started, and the port used + System.out.println("Webserver started on port " + port); + } + + + public static void main(String[] args) throws IOException { + + // set a default port number + int port = 8080; + + // parse the arguments for a port number + if (args.length > 0) + port = Integer.parseInt(args[0]); + + // Create the webserver instance + WebServer webServer = new WebServer(port); + + // start the webserver + webServer.start(); + } +} -- cgit v1.2.1