From 6d1377d623638c2483c0bb2df49070e822151ce6 Mon Sep 17 00:00:00 2001 From: kaiyuran <73236245+kaiyuran@users.noreply.github.com> Date: Wed, 20 Nov 2024 13:03:49 -0500 Subject: [PATCH 1/6] update server ports commented out port is to run on nest server --- app.py | 49 +++++++++++++++++++++++++++++++++++++++++++------ testGet.py | 4 ++-- 2 files changed, 45 insertions(+), 8 deletions(-) diff --git a/app.py b/app.py index 74b0a03..ed0e10c 100644 --- a/app.py +++ b/app.py @@ -175,6 +175,39 @@ def emojify(message): "fruit": "🍉", "refreshing": "🍉", "summer": "🍉", + + + + "eggplant": "🍆", + "aubergine": "🍆", + "banana": "🍌", + "peach": "🍑", + "cherries": "🍒", + "strawberry": "🍓", + "tomato": "🍅", + "avocado": "🥑", + "broccoli": "🥦", + "carrot": "🥕", + "corn": "🌽", + "cucumber": "🥒", + "lettuce": "🥬", + "mushroom": "🍄", + "pepper": "🌶️", + "hotpepper": "🌶️", + "potato": "🥔", + "sweetpotato": "🍠", + "croissant": "🥐", + "baguette": "🥖", + "pretzel": "🥨", + "cheese": "🧀", + "egg": "🥚", + "bacon": "🥓", + "pancakes": "🥞", + "poultryleg": "🍗", + "chicken": "🍗", + "meat": "🍖", + "bacon": "🥓", + } message = message.strip('"') @@ -201,19 +234,21 @@ def emojify(message): - - - app = Flask(__name__) -CORS(app) +CORS(app) + +#if __name__ == "__main__": +# app.run(host='0.0.0.0', port=33303) + @app.route('/getemoji', methods=['GET']) +# @cross_origin() def get_random_emoji(): # Get the 'letter' parameter from the URL message = request.args.get('message') print(message) - + final = emojify(message) # print(final) final = jsonify({"message": final})# emoji in JSON format @@ -222,4 +257,6 @@ def get_random_emoji(): return final if __name__ == '__main__': - app.run(debug=True) \ No newline at end of file + #app.run(debug=True) + app.run(port=33303) + # app.run(host='0.0.0.0', port=33303) \ No newline at end of file diff --git a/testGet.py b/testGet.py index 53c168f..5647325 100644 --- a/testGet.py +++ b/testGet.py @@ -1,7 +1,7 @@ import requests -url = "http://127.0.0.1:5000/getemoji" - +# url = "http://127.0.0.1:5501/getemoji" +url = "http://37.27.51.34:33303/getemoji" params = { "message": "I love chocolate donuts. I laugh at funny jokes about it. I think it is amazing." } From b9cd35ce973a2cced57966872c372e7901aaa400 Mon Sep 17 00:00:00 2001 From: kaiyuran <73236245+kaiyuran@users.noreply.github.com> Date: Wed, 20 Nov 2024 14:13:42 -0500 Subject: [PATCH 2/6] update port --- testGet.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testGet.py b/testGet.py index 5647325..be21cf3 100644 --- a/testGet.py +++ b/testGet.py @@ -1,7 +1,7 @@ import requests -# url = "http://127.0.0.1:5501/getemoji" -url = "http://37.27.51.34:33303/getemoji" +url = "http://127.0.0.1:33303/getemoji" +# url = "http://37.27.51.34:33303/getemoji" params = { "message": "I love chocolate donuts. I laugh at funny jokes about it. I think it is amazing." } From 36dcb98c18289e2306634a684aa7fadf55d7bd94 Mon Sep 17 00:00:00 2001 From: kaiyuran <73236245+kaiyuran@users.noreply.github.com> Date: Wed, 20 Nov 2024 14:14:46 -0500 Subject: [PATCH 3/6] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 671cf31..0923c2e 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ docs/_build/ dist/ venv/ .venv +tempCodeRunnerFile.py From d9edc071c64055ff89c3d1f7e8f3728aff24a136 Mon Sep 17 00:00:00 2001 From: kaiyuran <73236245+kaiyuran@users.noreply.github.com> Date: Wed, 20 Nov 2024 18:01:51 -0500 Subject: [PATCH 4/6] update README and emojis --- README.md | 4 ++++ app.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/README.md b/README.md index e69de29..9d1f5c6 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,4 @@ +#Emojify Server +This is a simple server that takes a string as input and returns the string with emojis. The server is written in Python and uses Flask as the web framework and I am running this on Hackclub's nest server. + +I have added a bunch of emojis manually but in the future I plan to use AI to predict the emojis based on the text. \ No newline at end of file diff --git a/app.py b/app.py index ed0e10c..567043c 100644 --- a/app.py +++ b/app.py @@ -208,6 +208,51 @@ def emojify(message): "meat": "🍖", "bacon": "🥓", + "sad": "😢", + "angry": "😡", + "mad": "😡", + "fury": "😡", + "rage": "😡", + "disgust": "🤢", + "sick": "🤢", + "vomit": "🤢", + "gross": "🤢", + "nausea": "🤢", + "unhappy": "😞", + "depressed": "😞", + "miserable": "😞", + "gloomy": "😞", + "despair": "😞", + "spy": "🕵️", + "detective": "🕵️", + "sleuth": "🕵️", + "investigate": "🕵️", + "search": "🕵️", + "inspect": "🕵️", + "dance": "💃", + "dancer": "💃", + "ballerina": "💃", + "tango": "💃", + "dancing": "🕺", + "twin": "👯", + "sisters": "👯", + "twins": "👯", + "ballet": "🩰", + "pointeshoes": "🩰", + "balletshoes": "🩰", + "shoes": "👟", + "heels": "👠", + "finish": "🏁", + "sign": "🚩", + "leaf": "🍃", + "plant": "🌱", + "flower": "🌸", + "blossom": "🌸", + "rose": "🌹", + "tulip": "🌷", + "sunflower": "🌻", + "daisy": "🌼", + "hibiscus": "🌺", } message = message.strip('"') From c9c29ffeec485c0d97ace782b78ad92264ea4efe Mon Sep 17 00:00:00 2001 From: kaiyuran <73236245+kaiyuran@users.noreply.github.com> Date: Wed, 20 Nov 2024 18:23:24 -0500 Subject: [PATCH 5/6] fix punctuation handling --- app.py | 49 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/app.py b/app.py index 567043c..691879e 100644 --- a/app.py +++ b/app.py @@ -5,6 +5,12 @@ import random def emojify(message): choiceWordDict = { + "hello": "👋", + "hi": "👋", + "hey": "👋", + "greetings": "👋", + "goodbye": "👋", + #happy face "happy": "😊", "joy": "😊", @@ -253,8 +259,36 @@ def emojify(message): "sunflower": "🌻", "daisy": "🌼", "hibiscus": "🌺", + "work": "🏢", + "office": "🏢", + "building": "🏢", + "construction": "🏗️", + "site": "🏗️", + "school": "🏫", + "university": "🏫", + "college": "🏫", + "hospital": "🏥", + "clinic": "🏥", + "doctor": "👩‍⚕️", + "nurse": "👩‍⚕️", + "therapist": "👩‍⚕️", + "healthcare": "👩‍⚕️", + "police": "👮", + "cop": "👮", + "law": "👮", + "enforcement": "👮", + "officer": "👮", + "movie": "🎥", + "film": "🎥", + "camera": "🎥", + "movies": "🎥", + "cinema": "🎥", + "theater": "🎭", + "drama": "🎭", + "acting": "🎭", + "perform": "🎭", } - + puncList = [".",",","!","?",";"] message = message.strip('"') message = message.strip("'") finalMessage = [] @@ -263,9 +297,12 @@ def emojify(message): for word in message: try: formWord = word.lower() - if formWord[-1] == ".": - finalMessage.append(word[:-1] + (choiceWordDict[formWord[:-1]] * random.randint(1,3)) +".") - else: + done = False + for punctuation in puncList: + if formWord[-1] == punctuation: + finalMessage.append(word[:-1] + (choiceWordDict[formWord[:-1]] * random.randint(1,3)) +punctuation) + done = True + if not done: finalMessage.append(word + choiceWordDict[word.lower()]) @@ -303,5 +340,5 @@ def get_random_emoji(): if __name__ == '__main__': #app.run(debug=True) - app.run(port=33303) - # app.run(host='0.0.0.0', port=33303) \ No newline at end of file + # app.run(port=33303) + app.run(host='0.0.0.0', port=33303) \ No newline at end of file From ca65d941567e054cb2ed73bf3cdd0c39c9d099c0 Mon Sep 17 00:00:00 2001 From: kaiyuran <73236245+kaiyuran@users.noreply.github.com> Date: Wed, 20 Nov 2024 18:24:29 -0500 Subject: [PATCH 6/6] more punctuation --- app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.py b/app.py index 691879e..c665dfc 100644 --- a/app.py +++ b/app.py @@ -288,7 +288,7 @@ def emojify(message): "acting": "🎭", "perform": "🎭", } - puncList = [".",",","!","?",";"] + puncList = [".",",","!","?",";", "'", '"', ":"] message = message.strip('"') message = message.strip("'") finalMessage = []