From 87141001cb308b65e3584967295b1240eebaade1 Mon Sep 17 00:00:00 2001 From: Vyacheslav K Date: Tue, 4 Feb 2025 18:36:55 +0300 Subject: [PATCH] Added html support --- README.md | 54 +++++++++++++++++++++++++++++++++++++++++++++++ main.py | 5 +++++ static/index.html | 0 3 files changed, 59 insertions(+) create mode 100644 README.md create mode 100644 static/index.html diff --git a/README.md b/README.md new file mode 100644 index 0000000..9614dfb --- /dev/null +++ b/README.md @@ -0,0 +1,54 @@ + +# Study task-1 + +Text transliteration service with API + + + +## Installation + +```bash + git clone https://git.moondev.space/themoon/study-task-1.git + cd study-task-1 + pip install -r requirements.txt + python3 main.py +``` +And open http://127.0.0.1:5000/ +## API Reference + +#### Transliterate and save text + +```http + POST /api/store +``` +Request JSON body: +| Parameter | Type | Description | +| :-------- | :------- | :------------------------- | +| `data` | `string` | **Required**. Text to transliterate | + +#### Get history + +```http + GET /api/history +``` +Request GET params: +| Parameter | Type | Description | +| :-------- | :------- | :-------------------------------- | +| `limit` | `integer` | **Required**. Number of records to display| + + + + +## Test example + +``` +curl --header "Content-Type: application/json" \ + --request POST \ + --data '{"data":"проверка"}' \ + http://localhost:5000/api/store +``` + +## Authors + +- [Vyacheslav K.](https://t.me/moon_devv) + diff --git a/main.py b/main.py index 032277e..893eb39 100644 --- a/main.py +++ b/main.py @@ -21,6 +21,11 @@ async def init_db(): # Инициализация БД """) await db.commit() + +@app.route('/') +def serve_index(): + return send_from_directory('./static', 'index.html') + @app.route('/api/store', methods=['POST']) # Транслитерация и сохранение в БД async def history_store(): try: diff --git a/static/index.html b/static/index.html new file mode 100644 index 0000000..e69de29