from pyodide.http import open_url import json api_endpoint = 'https://sfzdeisncmxwnvnzc2hje3k5ya0wfjma.lambda-url.ap-northeast-1.on.aws/' pyscript.write("suggestedword","おすすめ単語は soare です。") tmp_int = [-1] def client(*ags, **kws): input_word_a = Element("input_word_a") input_response_a = Element("input_response_a") input_word = input_word_a.element.value input_response = input_response_a.element.value if len(input_word) != 5: pyscript.write("leftwords","入力がおかしいようです。確認してください。") return if len(input_response) != 5 or input_response.count("o") + input_response.count("-") + input_response.count("x") != 5: pyscript.write("leftwords","入力がおかしいようです。確認してください。") return input_word_a.clear() input_response_a.clear() res = call_lambda(tmp_int[0],input_word,input_response) if int(res["number_of_candidates"]) == 0: pyscript.write("leftwords","候補単語数が0になりました。やり直してください。") pyscript.write("suggestedword","") yscript.write("candidates","") elif int(res["number_of_candidates"]) == 1: pyscript.write("leftwords","正解は " + str(res["candidates"])+" です。") pyscript.write("suggestedword","") pyscript.write("candidates","") else: pyscript.write("suggestedword","おすすめ単語は " + str(res["suggested_word"])+" です。") if int(res["number_of_candidates"]) <= 10: pyscript.write("candidates","残っている単語は " + str(res["candidates"])+" です。") pyscript.write("leftwords","残っている単語の数は "+str(res["number_of_candidates"])+" 個です。") tmp_int[0] = res["available_int"] def gen_params(params): ans = "" for key in params: ans += str(key) ans += "=" ans += str(params[key]) ans += "&" return ans[:-1] def call_lambda(word_list_int,input_word,input_response): params = {"word_list_int":str(word_list_int), "input_word": input_word, "input_response": input_response} url_with_params = f'{api_endpoint}?{gen_params(params)}' try: result = json.loads(open_url(url_with_params).read()) except Exception as e: #pyscript.write("suggestedword","エラーが発生しました。リロードしてやり直してください。") pyscript.write("suggestedword",e) tmp_int[0] = -1 return return result

wordleを解いてくれるくん






【入力方法】
緑色はo(小文字のオー)、黄色は-(半角のバー)、灰色はx(小文字のエックス)で記載してください。
例: ■■■■ → xx-oo