2024-11-12 22:53:39 +00:00
|
|
|
from flask import Flask, request, jsonify
|
2024-11-19 18:24:56 +00:00
|
|
|
from flask_cors import CORS
|
2024-11-12 22:53:39 +00:00
|
|
|
import random
|
|
|
|
|
|
|
|
def emojify(message):
|
|
|
|
|
|
|
|
choiceWordDict = {
|
|
|
|
#happy face
|
|
|
|
"happy": "😊",
|
|
|
|
"joy": "😊",
|
|
|
|
"content": "😊",
|
|
|
|
"smile": "😊",
|
|
|
|
"grateful": "😊",
|
|
|
|
"kind": "😊",
|
|
|
|
"warm": "😊",
|
|
|
|
"friendly": "😊",
|
|
|
|
"pleasant": "😊",
|
|
|
|
|
|
|
|
#laugh
|
|
|
|
"laugh": "😂",
|
|
|
|
"funny": "😂",
|
|
|
|
"lol": "😂",
|
|
|
|
"hilarious": "😂",
|
|
|
|
"joke": "😂",
|
|
|
|
"laughter": "😂",
|
|
|
|
"giggle": "😂",
|
|
|
|
"humor": "😂",
|
|
|
|
"meme": "😂",
|
|
|
|
"comedy": "😂",
|
|
|
|
|
|
|
|
#heart
|
|
|
|
"love": "❤️",
|
|
|
|
"heart": "❤️",
|
|
|
|
"affection": "❤️",
|
|
|
|
"adore": "❤️",
|
|
|
|
"romance": "❤️",
|
|
|
|
"care": "❤️",
|
|
|
|
"beloved": "❤️",
|
|
|
|
"fondness": "❤️",
|
|
|
|
"sweetheart": "❤️",
|
|
|
|
|
|
|
|
#heart face
|
|
|
|
"cute": "🥰",
|
|
|
|
"adorable": "🥰",
|
|
|
|
"sweet": "🥰",
|
|
|
|
"crush": "🥰",
|
|
|
|
"blush": "🥰",
|
|
|
|
"heartwarming": "🥰",
|
|
|
|
"charming": "🥰",
|
|
|
|
"affectionate": "🥰",
|
|
|
|
"darling": "🥰",
|
|
|
|
|
|
|
|
|
|
|
|
"amazing": "😍",
|
|
|
|
"admire": "😍",
|
|
|
|
"wow": "😍",
|
|
|
|
"beautiful": "😍",
|
|
|
|
"attractive": "😍",
|
|
|
|
"captivated": "😍",
|
|
|
|
"enchanted": "😍",
|
|
|
|
|
|
|
|
"think": "🤔",
|
|
|
|
"ponder": "🤔",
|
|
|
|
"wonder": "🤔",
|
|
|
|
"curious": "🤔",
|
|
|
|
"consider": "🤔",
|
|
|
|
"question": "🤔",
|
|
|
|
"reflect": "🤔",
|
|
|
|
"speculate": "🤔",
|
|
|
|
"doubt": "🤔",
|
|
|
|
"analyze": "🤔",
|
|
|
|
|
|
|
|
|
|
|
|
"grin": "😁",
|
|
|
|
"excited": "😁",
|
|
|
|
"positive": "😁",
|
|
|
|
"enthusiasm": "😁",
|
|
|
|
"joyful": "😁",
|
|
|
|
"cheerful": "😁",
|
|
|
|
"beam": "😁",
|
|
|
|
"delight": "😁",
|
|
|
|
|
|
|
|
"like": "👍",
|
|
|
|
"approval": "👍",
|
|
|
|
"agree": "👍",
|
|
|
|
"okay": "👍",
|
|
|
|
"support": "👍",
|
|
|
|
"endorse": "👍",
|
|
|
|
"respect": "👍",
|
|
|
|
"commend": "👍",
|
|
|
|
"thumb": "👍",
|
|
|
|
"thumbs": "👍",
|
|
|
|
|
|
|
|
"celebrate": "🎉",
|
|
|
|
"party": "🎉",
|
|
|
|
"event": "🎉",
|
|
|
|
"fun": "🎉",
|
|
|
|
"cheer": "🎉",
|
|
|
|
"festivity": "🎉",
|
|
|
|
"win": "🎉",
|
|
|
|
"success": "🎉",
|
|
|
|
"achievement": "🎉",
|
|
|
|
|
|
|
|
"fire": "🔥",
|
|
|
|
"hot": "🔥",
|
|
|
|
"intense": "🔥",
|
|
|
|
"awesome": "🔥",
|
|
|
|
"trending": "🔥",
|
|
|
|
"lit": "🔥",
|
|
|
|
"energy": "🔥",
|
|
|
|
"passion": "🔥",
|
|
|
|
"power": "🔥",
|
|
|
|
|
|
|
|
# Pizza
|
|
|
|
"pizza": "🍕",
|
|
|
|
"cheese": "🍕",
|
|
|
|
"slice": "🍕",
|
|
|
|
"italian": "🍕",
|
|
|
|
"pepperoni": "🍕",
|
|
|
|
|
|
|
|
# Burger
|
|
|
|
"burger": "🍔",
|
|
|
|
"cheeseburger": "🍔",
|
|
|
|
"fries": "🍔",
|
|
|
|
"grill": "🍔",
|
|
|
|
"food": "🍔",
|
|
|
|
|
|
|
|
# Taco
|
|
|
|
"taco": "🌮",
|
|
|
|
"mexican": "🌮",
|
|
|
|
"salsa": "🌮",
|
|
|
|
"spicy": "🌮",
|
|
|
|
"guacamole": "🌮",
|
|
|
|
|
|
|
|
# Sushi
|
|
|
|
"sushi": "🍣",
|
|
|
|
"fish": "🍣",
|
|
|
|
"rice": "🍣",
|
|
|
|
"soysauce": "🍣",
|
|
|
|
"japanese": "🍣",
|
|
|
|
|
|
|
|
# Ice Cream
|
|
|
|
"icecream": "🍦",
|
|
|
|
"dessert": "🍦",
|
|
|
|
"vanilla": "🍦",
|
|
|
|
"cone": "🍦",
|
|
|
|
"frozen": "🍦",
|
|
|
|
|
|
|
|
# Apple
|
|
|
|
"apple": "🍎",
|
|
|
|
"healthy": "🍎",
|
|
|
|
"red": "🍎",
|
|
|
|
"snack": "🍎",
|
|
|
|
|
|
|
|
# Cake
|
|
|
|
"cake": "🍰",
|
|
|
|
"birthday": "🍰",
|
|
|
|
"celebration": "🍰",
|
|
|
|
|
|
|
|
# Donut
|
|
|
|
"donut": "🍩",
|
2024-11-13 02:38:38 +00:00
|
|
|
"donuts": "🍩",
|
2024-11-12 22:53:39 +00:00
|
|
|
"glazed": "🍩",
|
|
|
|
"glaze": "🍩",
|
|
|
|
"sprinkles": "🍩",
|
|
|
|
# Bread
|
|
|
|
"bread": "🍞",
|
|
|
|
"toast": "🍞",
|
|
|
|
"bakery": "🍞",
|
|
|
|
"sandwich": "🍞",
|
|
|
|
"loaf": "🍞",
|
|
|
|
|
|
|
|
# Watermelon
|
|
|
|
"watermelon": "🍉",
|
|
|
|
"fruit": "🍉",
|
|
|
|
"refreshing": "🍉",
|
|
|
|
"summer": "🍉",
|
2024-11-20 18:03:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"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": "🥓",
|
|
|
|
|
2024-11-12 22:53:39 +00:00
|
|
|
}
|
|
|
|
|
2024-11-13 01:12:47 +00:00
|
|
|
message = message.strip('"')
|
|
|
|
message = message.strip("'")
|
2024-11-12 22:53:39 +00:00
|
|
|
finalMessage = []
|
|
|
|
print("message is:",message)
|
|
|
|
message = message.split(" ")
|
|
|
|
for word in message:
|
|
|
|
try:
|
2024-11-13 02:38:38 +00:00
|
|
|
formWord = word.lower()
|
|
|
|
if formWord[-1] == ".":
|
2024-11-13 03:13:50 +00:00
|
|
|
finalMessage.append(word[:-1] + (choiceWordDict[formWord[:-1]] * random.randint(1,3)) +".")
|
2024-11-13 02:38:38 +00:00
|
|
|
else:
|
|
|
|
finalMessage.append(word + choiceWordDict[word.lower()])
|
|
|
|
|
|
|
|
|
2024-11-13 03:13:50 +00:00
|
|
|
|
2024-11-12 22:53:39 +00:00
|
|
|
except:
|
|
|
|
finalMessage.append(word)
|
|
|
|
pass
|
|
|
|
print(finalMessage)
|
|
|
|
final =" ".join([str(item) for item in finalMessage])
|
|
|
|
return final
|
|
|
|
|
|
|
|
|
2024-11-19 18:21:42 +00:00
|
|
|
|
2024-11-20 18:03:49 +00:00
|
|
|
app = Flask(__name__)
|
|
|
|
CORS(app)
|
2024-11-19 18:21:42 +00:00
|
|
|
|
2024-11-20 18:03:49 +00:00
|
|
|
#if __name__ == "__main__":
|
|
|
|
# app.run(host='0.0.0.0', port=33303)
|
2024-11-19 18:21:42 +00:00
|
|
|
|
|
|
|
|
2024-11-12 22:53:39 +00:00
|
|
|
@app.route('/getemoji', methods=['GET'])
|
2024-11-20 18:03:49 +00:00
|
|
|
# @cross_origin()
|
2024-11-12 22:53:39 +00:00
|
|
|
def get_random_emoji():
|
|
|
|
# Get the 'letter' parameter from the URL
|
|
|
|
message = request.args.get('message')
|
|
|
|
print(message)
|
2024-11-13 02:38:38 +00:00
|
|
|
|
2024-11-20 18:03:49 +00:00
|
|
|
|
2024-11-12 22:53:39 +00:00
|
|
|
final = emojify(message)
|
2024-11-13 03:13:50 +00:00
|
|
|
# print(final)
|
2024-11-13 02:38:38 +00:00
|
|
|
final = jsonify({"message": final})# emoji in JSON format
|
|
|
|
# final = jsonify({final: 1})# emoji in JSON format
|
|
|
|
|
2024-11-12 22:53:39 +00:00
|
|
|
return final
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2024-11-20 18:03:49 +00:00
|
|
|
#app.run(debug=True)
|
|
|
|
app.run(port=33303)
|
|
|
|
# app.run(host='0.0.0.0', port=33303)
|