Skip to content

Commit

Permalink
feat(app): get word api and optimized dfa code
Browse files Browse the repository at this point in the history
  • Loading branch information
arn355 committed Oct 19, 2023
1 parent 38192b6 commit a5bf566
Show file tree
Hide file tree
Showing 3 changed files with 291 additions and 1,532 deletions.
118 changes: 118 additions & 0 deletions database/words.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
wordlist = [
{
"word": "understand",
"images": ["https://cdn.discordapp.com/attachments/1153342096460222465/1164435096850403520/IMG_4997.png?ex=654333b1&is=6530beb1&hm=750745cc9fbf3dfb4eb90a03465df7d308c54e1d03f1d78c74f1e1d32bddac8b&",
"https://cdn.discordapp.com/attachments/1153342096460222465/1164435097085292605/IMG_4981.jpg?ex=654333b1&is=6530beb1&hm=689ac257f672a710ae66fc266dc4e1ffd6a22284e07346b0d4b85170aec49bfd&"]
},
{
"word": "kingkong",
"images": ["https://cdn.discordapp.com/attachments/1153342096460222465/1164432107238592592/IMG_4982.jpg?ex=654330e8&is=6530bbe8&hm=131ea2d01b815aa601bbdbb1f7930e3ac2f22334324415663f526ca36d813de0&",
"https://cdn.discordapp.com/attachments/1153342096460222465/1164432107238592592/IMG_4982.jpg?ex=654330e8&is=6530bbe8&hm=131ea2d01b815aa601bbdbb1f7930e3ac2f22334324415663f526ca36d813de0&"]
},
{
"word": "money",
"images": ["https://cdn.discordapp.com/attachments/1153342096460222465/1164432629500751893/IMG_4984.jpg?ex=65433164&is=6530bc64&hm=971230244b2b99ea8662013c8e358abddb3a9c9f3596ad0ce69b370d87e420d1&",
"https://cdn.discordapp.com/attachments/1153342096460222465/1164432629853081621/IMG_4985.jpg?ex=65433165&is=6530bc65&hm=370226e59ffad8616845f04812b91b275f47289931afedc174d191cc319f0b08&"]
},
{
"word": "disband",
"images": ["https://cdn.discordapp.com/attachments/1153342096460222465/1164433098243575888/IMG_4987.png?ex=654331d4&is=6530bcd4&hm=fb600293d52a632897ea84403f64b14154af1ffaed5e98a483e4558b32cf1b65&",
"https://cdn.discordapp.com/attachments/1153342096460222465/1164433098512007178/IMG_4988.jpg?ex=654331d4&is=6530bcd4&hm=013ceba168d6845e2ab8fb3bf9c623556fe115387a178a75cca7f72e2dec9e6a&"]
},
{
"word": "architecture",
"images": ["https://cdn.discordapp.com/attachments/1153342096460222465/1164433875188072509/IMG_4989.png?ex=6543328d&is=6530bd8d&hm=ca772e9f0ca2cc73bbda1f32592c929591bb082dc6b1467ff4e39d83e7750d4f&",
"https://cdn.discordapp.com/attachments/1153342096460222465/1164433875523600384/IMG_4991.png?ex=6543328e&is=6530bd8e&hm=127cc719860f4c4f8d132126fd446308e18f450a234c12a762ccc352fde88a60&"]
},
{
"word": "Entertainment",
"images": ["https://cdn.discordapp.com/attachments/1153342096460222465/1164434425480761374/IMG_4992.jpg?ex=65433311&is=6530be11&hm=4cddcfd233d71ed15780b07566d95042cc3f4e1d7fec2fc7a5265469b6d72688&",
"https://cdn.discordapp.com/attachments/1153342096460222465/1164434425736605756/IMG_4993.jpg?ex=65433311&is=6530be11&hm=890b1b35d674275e08f12ed5ec61bc123c2528755ea08dc05ab82c6d0e24704e&",
"https://cdn.discordapp.com/attachments/1153342096460222465/1164434425950507010/IMG_4995.jpg?ex=65433311&is=6530be11&hm=2bda2a8b98a4097d85e41421f85b0d1f08ffe66467ad0896d50f808304bc361f&"]
},
{
"word": "Investment",
"images": ["https://cdn.discordapp.com/attachments/1153342096460222465/1164470794106183700/image.png?ex=654354f0&is=6530dff0&hm=cbf0b9a0e922a6b8cc520b285f2b359063b93aeb966176b571e7a8e8d6da94cd&",
"https://cdn.discordapp.com/attachments/1153342096460222465/1164470794462695495/1200px-Compass_Rose_English_West.png?ex=654354f0&is=6530dff0&hm=3a411c8a3c1de6465aad8e124330895d46c344892251da4972553f854bf034b8&",
"https://cdn.discordapp.com/attachments/1153342096460222465/1164470794815021126/e0b980e0b8a1e0b988e0b899e0b981e0b884e0b8a3e0b8b0.png?ex=654354f0&is=6530dff0&hm=1f283218b6e6d8b4021b3bf51756edc9da88655a44142848ae8a5d6bc4c312c2&"]
},
{
"word": "battlefield",
"images": ["https://cdn.discordapp.com/attachments/1153342096460222465/1164469891739418724/640px-Richard_Caton_Woodville27s_The_Battle_of_Towton.png?ex=65435418&is=6530df18&hm=4b448655cd5e76cfd7970fa013a01630fcb46961ddd5d5edf46d61741ab97507&",
"https://cdn.discordapp.com/attachments/1153342096460222465/1164469892184018965/photo-1584623572201-d0385667e46d.png?ex=65435419&is=6530df19&hm=078d2833607511d4855768667a969fb68a8c7db616a53f97d1f93a53d39a56dc&"]
},
{
"word": "leadership",
"images": ["https://cdn.discordapp.com/attachments/1153342096460222465/1164436824236752987/shutterstock_500593225_354026.png?ex=6543354d&is=6530c04d&hm=3452fe19e8eae25feed12daf96b4d0a12c5ede16c4c45d424bdb8c6dc291afa5&",
"https://cdn.discordapp.com/attachments/1153342096460222465/1164436824618450944/FEATURED_MSC-Virtuosa.png?ex=6543354d&is=6530c04d&hm=956e64f74ecbf942de53212993a1d87fb8ebce972beda21c68e467227275f580&"]
},
{
"word": "Challenge",
"images": ["https://cdn.discordapp.com/attachments/1153342096460222465/1164434407696891984/IMG_1268.png?ex=6543330c&is=6530be0c&hm=e9ea3a23fb0fe278d926da2a5381b6f9cb16aa22247ad81fad8ee996f1cabfbe&",
"https://cdn.discordapp.com/attachments/1153342096460222465/1164434407965347841/IMG_1267.png?ex=6543330d&is=6530be0d&hm=36221a34608ac17e604cef4a0345472af0bdc8789c99e7ddd56df7712f613c77&"]
},
{
"word": "Remember",
"images": ["https://cdn.discordapp.com/attachments/1153342096460222465/1164443830465081447/remember1.png?ex=65433bd3&is=6530c6d3&hm=f8eb67697bc3e146e54401dcf32330991d0e205207c11ee8c2c13ddb9b408818&",
"https://cdn.discordapp.com/attachments/1153342096460222465/1164443830754492456/remember2.jpg?ex=65433bd3&is=6530c6d3&hm=38ae0491ba82d47b9a1bd9676b226f1985c3d2c566f5a867da1e5b971ea756f1&",
"https://cdn.discordapp.com/attachments/1153342096460222465/1164443831010332672/remember3.png?ex=65433bd3&is=6530c6d3&hm=3c8f7d39bf4e124de6cb179b120d025413816669fe6fda0a9b697ef6347365ef&"]
},
{
"word": "concert",
"images": ["https://cdn.discordapp.com/attachments/1153342096460222465/1164435569011609651/IMG_4999.jpg?ex=65433421&is=6530bf21&hm=306cfcdb6e4610d53059f4d29015e20bdf8f55a5eb109b12d4984284c5cfe9c5&",
"https://cdn.discordapp.com/attachments/1153342096460222465/1164435569271640064/IMG_5001.jpg?ex=65433421&is=6530bf21&hm=31d04cb77083554c688cb3cb6aa393f140f09cc612b45fb173bde538caa7e33d&"]
},
{
"word": "nuclear",
"images": ["https://cdn.discordapp.com/attachments/1153342096460222465/1164468376354164746/Picture1.png?ex=654352af&is=6530ddaf&hm=16052ec7e5d456fd54dc2e25049031a73343d78c51489da23eea2dd68b1d15b9&",
"https://cdn.discordapp.com/attachments/1153342096460222465/1164468376874274876/4269.png?ex=654352af&is=6530ddaf&hm=2fa3e6eda83c69cca845d76b6fe1c6015ab7170ce1b1da3ed12233e0f70078f3&"]
},
{
"word": "Deadline",
"images": ["https://cdn.discordapp.com/attachments/1153342096460222465/1164439694008909894/ISS_17050_04738.png?ex=654337f9&is=6530c2f9&hm=2a8c2c499ae0c86b10da0ad77cf5bced60df658918667d8d01b42f443bb9b79f&",
"https://cdn.discordapp.com/attachments/1153342096460222465/1164439694264778812/5cff802d48d74607ac929ec2751684e9.png?ex=654337f9&is=6530c2f9&hm=f7e2dcce109355f2faa1ab4fdd4e7aafacc17cb9bbe6714dd54eea7d404fadd6&"]
},
{
"word": "Facebook",
"images": ["https://cdn.discordapp.com/attachments/1153342096460222465/1164434988268273674/GettyImages-1092658864_hero-1024x575.png?ex=65433397&is=6530be97&hm=15d5673e377eca6df592870b41fab1c3b43583f9a3c7b68998d8e6ce59314694&",
"https://cdn.discordapp.com/attachments/1153342096460222465/1164434988763185172/Gutenberg_Bible2C_Lenox_Copy2C_New_York_Public_Library2C_2009.png?ex=65433397&is=6530be97&hm=f0228e6e22f92791f19a3ea2e63d6326e5595c185c8cd87cf5505bdc599ce099&"]
},
{
"word": "microwave",
"images": ["https://cdn.discordapp.com/attachments/1153342096460222465/1164438008511082577/image.png?ex=65433667&is=6530c167&hm=5075fe87937f13cfeb105a96a4f3bb8ce7ae061db5519ee532a494ed2cde94b4&",
"https://cdn.discordapp.com/attachments/1153342096460222465/1164438008842428466/flying-drone-over-large-lake-with-view-of-mountain-peaks.png?ex=65433667&is=6530c167&hm=39c21c3c51648e32fd506e24e6dce4dc2b09170a83463115158e89d51809cc58&"]
},
{
"word": "Arduino",
"images": ["https://cdn.discordapp.com/attachments/1153342096460222465/1161688119217762324/IMG_1269.png?ex=65426fde&is=652ffade&hm=8c524c82e77529cf69fe8ce8bb067b6100a201cbf209d0f3508b7dc6f97ceeda&",
"https://cdn.discordapp.com/attachments/1153342096460222465/1161688119431659530/IMG_1270.png?ex=65426fde&is=652ffade&hm=f1667c6f9212f7a47be5124cb1bbad13246d216af00aac203be25173cb675c4f&",
"https://cdn.discordapp.com/attachments/1153342096460222465/1161688119716876328/IMG_1271.jpg?ex=65426fde&is=652ffade&hm=8e3dc76e85e0551e3308c245b49850b9d587109831d6d33a428df9455420ae5f&"]
},
{
"word": "Tornado",
"images": ["https://cdn.discordapp.com/attachments/1153342096460222465/1164434178755014706/latest.png?ex=654332d6&is=6530bdd6&hm=31cb3225717a9de79633a8fdd3e3de47d9556f6259364003088e5513da7b7635&",
"https://cdn.discordapp.com/attachments/1153342096460222465/1164434179606454272/IMG_1274.png?ex=654332d6&is=6530bdd6&hm=fccd2280b90d816951c641df8f694e0b4887ee53a7a6315ff14de5dbbec19fb4&",
"https://cdn.discordapp.com/attachments/1153342096460222465/1164434180025892935/IMG_1272.png?ex=654332d6&is=6530bdd6&hm=127df8a62a861a6093837d0c6e269cd7213001a678111906fca3d5d49bcae7a9&"]
},
{
"word": "lipstick",
"images": ["https://cdn.discordapp.com/attachments/1153342096460222465/1164467022239903754/11687-v.png?ex=6543516c&is=6530dc6c&hm=bf6a6f59f3e30e8a45539d48827af397e8b37953dabeb56fffebb353dd83e05a&",
"https://cdn.discordapp.com/attachments/1153342096460222465/1164467022617399339/stick_0.png?ex=6543516c&is=6530dc6c&hm=6a7ad4c9a236b5c25ebf2ae623d83edad9943deee3a74678269d9a3ecfffea9e&"]
},
{
"word": "Fantasy",
"images": ["https://cdn.discordapp.com/attachments/1153342096460222465/1164436095912640553/Mainstays-12-3-Speed-Oscillating-Table-Fan-FT30-8MBB-Black_0eb01f80-ee74-4343-b0a7-2629f7fae4b6.png?ex=6543349f&is=6530bf9f&hm=5e02f95b54d3a3b0838b3263be32b4fec0ea53dd70a390adaa93da1f3906a394&",
"https://cdn.discordapp.com/attachments/1153342096460222465/1164436096273354824/81557-thumbnail.png?ex=6543349f&is=6530bf9f&hm=31b4872438241a97674bbb32173b3598f0614d4ca994314efef2f715f760d3cd&",
"https://cdn.discordapp.com/attachments/1153342096460222465/1164436098336968714/Atlantic_near_Faroe_Islands.png?ex=654334a0&is=6530bfa0&hm=e99fc18d4d553b8a3ee7192784a4fbd43911b8c3595c15e8237d668cc84e2aab&"]
},
{
"word": "werewolf",
"images": ["https://cdn.discordapp.com/attachments/1153342096460222465/1164477728578355310/baby-sound.jpg?ex=65435b65&is=6530e665&hm=5039c3679750bc4884a6112acd81b975df24f10b1bc178f3365a94691aa4cae7&",
"https://cdn.discordapp.com/attachments/1153342096460222465/1164477728859357224/powerpuff-girls-faint.png?ex=65435b65&is=6530e665&hm=1022100435c4ed24133f57aadf6243a792329c0f7d6a32387dbd4725ba918645&"]
},
{
"word": "frenchfries",
"images": ["https://cdn.discordapp.com/attachments/1153342096460222465/1164440419703193671/Flag-France.png?ex=654338a6&is=6530c3a6&hm=fd513d7890e976aa0eae2a1521edcd61a12afa9528da6dccae913ac00c859a78&",
"https://cdn.discordapp.com/attachments/1153342096460222465/1164440420311371848/23FLEX-superJumbo.png?ex=654338a6&is=6530c3a6&hm=2fdd3fb367019adf2a1ca5d9dbb9f03784b57171680e39e644cf4fcce3add1d9&"]
},
]
11 changes: 10 additions & 1 deletion routes/route.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
from fastapi import APIRouter
from fastapi import APIRouter, HTTPException
from utils.words_dfa import isAccepted
from database.words import wordlist
import random

router = APIRouter()


@router.get("/word/check")
async def check_word(word: str):
if not word.isalpha():
raise HTTPException(status_code=400, detail="Only alphabet character.");
return (isAccepted(word.lower()))

@router.get("/words")
async def get_words(words: int = 5):
words = 22 if words > 22 else words
return random.sample(wordlist, words);
Loading

0 comments on commit a5bf566

Please sign in to comment.