{"id":18073326,"url":"https://github.com/melihov87/blog_flask","last_synced_at":"2026-04-16T19:43:25.767Z","repository":{"id":259186450,"uuid":"876431054","full_name":"melihov87/blog_flask","owner":"melihov87","description":"API to Elasticsearch engine","archived":false,"fork":false,"pushed_at":"2024-11-02T11:37:01.000Z","size":152,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-11T15:29:38.825Z","etag":null,"topics":["api","elasticsearch","flask"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/melihov87.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-22T00:38:29.000Z","updated_at":"2024-11-02T11:37:05.000Z","dependencies_parsed_at":"2024-10-23T10:38:55.036Z","dependency_job_id":"9b5df4b7-52c9-4b32-a62d-7f12559a393e","html_url":"https://github.com/melihov87/blog_flask","commit_stats":null,"previous_names":["melihov87/blog_flask"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/melihov87%2Fblog_flask","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/melihov87%2Fblog_flask/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/melihov87%2Fblog_flask/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/melihov87%2Fblog_flask/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/melihov87","download_url":"https://codeload.github.com/melihov87/blog_flask/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247378141,"owners_count":20929296,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","elasticsearch","flask"],"created_at":"2024-10-31T10:06:07.934Z","updated_at":"2026-04-16T19:43:20.714Z","avatar_url":"https://github.com/melihov87.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flask REST API to Elasticsearch\n\nThis project is a simple web application on Flask that interacts with Elasticsearch to create, read, update, delete, and search for posts.\nThe project uses containerization with Docker, which makes it easy to deploy an application with the necessary dependencies.\n\n\n## API\n\nThe main application file on Flask. \u003cbr\u003e\nThe main goal is to provide an API for managing posts using Elasticsearch:\n\u003cbr\u003e\n\u003cbr\u003e\n* ### _Getting posts._ \u003cbr\u003e\n\n```json\nGET http://localhost:5001/posts/full\n```\n\n* ### _Search for posts by title and content with pagination support._ \u003cbr\u003e\n\n```json\nGET http://localhost:5001/posts/search?q=Hello\u0026page=1\u0026per_page=100\n```\n\n* ### _Getting a post by ID._ \u003cbr\u003e\n\n```json\nGET http://localhost:5001/posts/11\n```\n\n```json\n{\n        \"title\": \"My eleventh Post\",\n        \"content\": \"Hello, world!\"\n}\n```\n```json\n        {\n                \"_index\": \"posts\",\n                \"_type\": \"_doc\",\n                \"_id\": \"11\",\n                \"_version\": 2,\n                \"result\": \"updated\",\n                \"_shards\": {\n                        \"total\": 2,\n                        \"successful\": 1,\n                        \"failed\": 0\n                        },\n                \"_seq_no\": 111,\n                \"_primary_term\": 36\n        }\n```\n\n* ### _Creating a new post._\n\n```json\nPOST http://localhost:5001/posts\n```\n\n```json\n{\n        \"title\": \"My third Post\",\n        \"content\": \"Hello, world!\"\n}\n```\n\n```json\n        {\n                \"_index\": \"posts\",\n                \"_type\": \"_doc\",\n                \"_id\": \"3\",\n                \"_version\": 2,\n                \"result\": \"updated\",\n                \"_shards\": {\n                        \"total\": 2,\n                        \"successful\": 1,\n                        \"failed\": 0\n                        },\n                \"_seq_no\": 116,\n                \"_primary_term\": 36\n        }\n```\n\n* ### _Updating an existing post by ID._\n\n```json\nPUT http://localhost:5001/posts/2\n```\n\n```json\n{\n        \"title\": \"My Second Post3\",\n        \"content\": \"Hello, world!3\"\n}\n```\n```json\n        {\n                \"_index\": \"posts\",\n                \"_type\": \"_doc\",\n                \"_id\": \"2\",\n                \"_version\": 2,\n                \"result\": \"updated\",\n                \"_shards\": {\n                        \"total\": 2,\n                        \"successful\": 1,\n                        \"failed\": 0\n                        },\n                \"_seq_no\": 112,\n                \"_primary_term\": 36\n        }\n```\n* ### _Deleting a post by ID._\n```json\nDELETE http://localhost:5001/posts/3\n```\n\n```json\n        {\n                \"_index\": \"posts\",\n                \"_type\": \"_doc\",\n                \"_id\": \"3\",\n                \"_version\": 2,\n                \"result\": \"deleted\",\n                \"_shards\": {\n                        \"total\": 2,\n                        \"successful\": 1,\n                        \"failed\": 0\n                        },\n                \"_seq_no\": 113,\n                \"_primary_term\": 36\n        }\n```\n\nElasticsearch is pinged to check availability before launching the application. \u003cbr\u003e\nAll interactions with Elasticsearch are performed using its Python client. \u003cbr\u003e\n\u003cbr\u003e\n\n\u003e.flake8:\u003cbr\u003e\n\nThe configuration file for the flake8 tool, which checks the code for compliance with PEP8 standards (Python code style). \u003cbr\u003e\nContains rules and exceptions for code validation.\u003c/p\u003e \u003cbr\u003e\n\n\n\u003e.gitignore:\u003cbr\u003e\n\nA list of files and directories that should not be monitored by the Git version control system. \u003cbr\u003e\nFor example, temporary files, generated files, Python environments, etc.\u003c/p\u003e \u003cbr\u003e\n\n\n\u003e.pylintrc:\u003cbr\u003e\n\nThe configuration file for the pylint tool, which performs static code analysis. \u003cbr\u003e\nIt contains settings for checking the style, code quality, and various warnings.\u003c/p\u003e \u003cbr\u003e\n\n\n\u003edocker-compose.yml:\u003cbr\u003e\n\nA file for Docker Compose that describes how to run multiple containers at the same time. \u003cbr\u003e\nTwo containers are launched in this project: \u003cbr\u003e\n    flask_app: A container for a web application on Flask. \u003cbr\u003e\n    elasticsearch: A container with Elasticsearch for storing and searching data. \u003cbr\u003e\nAutomatically binds containers so that the Flask application can interact with Elasticsearch.\u003c/p\u003e \u003cbr\u003e\n\n\n\u003eDockerfile:\u003cbr\u003e\n\nA script that describes the steps to create a Docker image of a Flask application. \u003cbr\u003e\n### Basic steps:\n- Uses a basic Python image. \u003cbr\u003e\n- Sets the necessary dependencies from requirements.txt . \u003cbr\u003e\n- Copies the source code of the application to the container. \u003cbr\u003e\n- Launches the Flask application. \u003cbr\u003e\n### Example of sections: \u003cbr\u003e\n- FROM python:3.9: Basic image. \u003cbr\u003e\n- COPY . /app: Copy project files. \u003cbr\u003e\n- RUN pip install -r requirements.txt : Installing dependencies. \u003cbr\u003e\n- CMD [\"python\", \"app.py \"]: Launching the application. \u003cbr\u003e\n\u003cbr\u003e\n\n\n\u003emypy.ini:\u003cbr\u003e\n\nThe configuration file for the mypy tool that checks type annotations in Python. \u003cbr\u003e\nHelps with static type checking, which improves code quality and helps prevent errors.\u003cbr\u003e\n\n\n\u003epre-commit.sh:\u003cbr\u003e\n\nA script for automatically checking the code before committing to Git. \u003cbr\u003e\nIt usually contains commands to run linters, tests, or other code checks before committing changes. \u003cbr\u003e\nExample: running flake8, pylint, or tests with pytest to make sure that the code meets the standards before making changes to the repository.\u003cbr\u003e\n\u003cbr\u003e\n\n### Code description:\u003cbr\u003e\n\nApplication initialization: A Flask application is created, a connection to Elasticsearch is established, and its readiness is checked through the wait_for_elasticsearch function.\u003cbr\u003e\n\u003cbr\u003e\n\n### Routing and API:\u003cbr\u003e\n- The code implements basic CRUD operations for posts: \u003cbr\u003e\n        - Receiving, creating, updating, deleting posts. \u003cbr\u003e\n        - Search for posts using full-text search in the title and content fields. \u003cbr\u003e\n- Elasticsearch is used as a data warehouse.\u003cbr\u003e\n\u003cbr\u003e\n\n### Exception handling:\u003cbr\u003e\n\nIf the document is not found or another error has occurred, an error with the 404 code and description is returned to the client.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmelihov87%2Fblog_flask","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmelihov87%2Fblog_flask","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmelihov87%2Fblog_flask/lists"}