私立PDD図書館・百科辞書のLZHファイルをapi.pyと同じディレクトリに置いて展開し、以下のような配置にしてください。
.
├── api.py
├── a
│ ├── あ
│ ├── い
│ ├── う
...
│ └── おくら
├── ha
│ ├── は
│ ├── ひ
...
依存関係を入れてください。Pythonは多分3.7以降くらいで動きます。
$ pip install flask
あとは以下のコマンドでAPIが起きます。
$ python3 api.py
リクエストを飛ばすと意味が返ってきます。
$ curl -s 'localhost:5000/%E3%81%82'
{"spelling": "あ", "meaning": ["【ア】\n◇[英]a-/(母音の前で)an-\n○[接頭辞]詞につけて副詞または形容詞を形成する要素。\n◎アフット(afoot):進行 中で。\nアショア(ashore):浜へ・浜に。\nアウェイク(asleep):眠らずに。\nアスリープ(asleep):眠って。", "【ア】\n◇[英]a-/(母音の前で)an-\n○[接頭辞]「非・無」を表す語形成要素。\n◎アジリア(agyria):脳回欠損。\nアタクシア(ataxia):運動失調。\nアグノージア(agnosia):失認。\nアカルキュリア(acalculia):失算。"], "error": ""}
$ curl -s 'localhost:5000/%E3%81%82' | jq .
{
"spelling": "あ",
"meaning": [
"【ア】\n◇[英]a-/(母音の前で)an-\n○[接頭辞]詞につけて副詞または形容詞を形成する要素。\n◎アフット(afoot):進行中で。\nアショア(ashore):浜へ・浜に。\nアウェイク(asleep):眠らずに。\nアスリープ(asleep):眠って。",
"【ア】\n◇[英]a-/(母音の前で)an-\n○[接頭辞]「非・無」を表す語形成要素。\n◎アジリア(agyria):脳回欠損。\nアタクシア(ataxia):運動失調。\nア グノージア(agnosia):失認。\nアカルキュリア(acalculia):失算。"
],
"error": ""
}