{"id":20703845,"url":"https://github.com/euiyounghwang/python-flask-basic","last_synced_at":"2026-04-11T18:02:34.633Z","repository":{"id":219320066,"uuid":"748746211","full_name":"euiyounghwang/python-flask-basic","owner":"euiyounghwang","description":"python-flask-basic","archived":false,"fork":false,"pushed_at":"2024-02-28T01:29:25.000Z","size":265,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-17T19:55:24.951Z","etag":null,"topics":["alembic","docker","docker-compose","elasticsearch","flask","flask-connexion","kafka","kafka-consumer","kafka-producer","poetry","pytest","python3","rabbitmq","rabbitmq-consumer","rest-api-framework","restapi-framework","shell-script","swagger","swagger-ui","thread"],"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/euiyounghwang.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-01-26T17:14:51.000Z","updated_at":"2024-02-10T05:27:27.000Z","dependencies_parsed_at":"2024-02-11T23:23:56.550Z","dependency_job_id":"e268ca2f-0085-4126-8fc9-0045d5a9af4a","html_url":"https://github.com/euiyounghwang/python-flask-basic","commit_stats":null,"previous_names":["euiyounghwang/python-flask-basic"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/euiyounghwang%2Fpython-flask-basic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/euiyounghwang%2Fpython-flask-basic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/euiyounghwang%2Fpython-flask-basic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/euiyounghwang%2Fpython-flask-basic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/euiyounghwang","download_url":"https://codeload.github.com/euiyounghwang/python-flask-basic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242970696,"owners_count":20214853,"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":["alembic","docker","docker-compose","elasticsearch","flask","flask-connexion","kafka","kafka-consumer","kafka-producer","poetry","pytest","python3","rabbitmq","rabbitmq-consumer","rest-api-framework","restapi-framework","shell-script","swagger","swagger-ui","thread"],"created_at":"2024-11-17T01:09:47.045Z","updated_at":"2026-04-11T18:02:34.580Z","avatar_url":"https://github.com/euiyounghwang.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# python-flask-basic\n\u003cimg src=\"https://img.shields.io/badge/Flask-000000?style=for-the-badge\u0026logo=flask\u0026logoColor=white\" /\u003e \u003cimg src=\"https://img.shields.io/badge/PostgreSQL-316192?style=for-the-badge\u0026logo=postgresql\u0026logoColor=white\" /\u003e \u003cimg src=\"https://img.shields.io/badge/Apache_Kafka-231F20?style=for-the-badge\u0026logo=apache-kafka\u0026logoColor=white\" /\u003e  \u003cimg src=\"https://img.shields.io/badge/Docker-2CA5E0?style=for-the-badge\u0026logo=docker\u0026logoColor=white\" /\u003e \u003cimg src=\"https://img.shields.io/badge/Swagger-85EA2D?style=for-the-badge\u0026logo=Swagger\u0026logoColor=white\" /\u003e \u003cimg src=\"https://img.shields.io/badge/Elastic_Search-005571?style=for-the-badge\u0026logo=elasticsearch\u0026logoColor=white\" /\u003e\n\n\u003ci\u003eConnexion is a modern Python web framework (build \u0026 install a enviroment using this script `source ./create_virtual_env.sh`) that makes spec-first and api-first development easy. You describe your API in an OpenAPI (or swagger) specification with as much detail as you want and Connexion will guarantee that it works as you specified. (It's very useful tool to build a number of schemas for database, \u003ci\u003ehttps://dbdiagram.io/d/65b83f0bac844320aefd041e\u003c/i\u003e)\n- It can be test a few function as background job (a process that runs in the background, `https://github.com/euiyounghwang/python-flask-basic/blob/master/job/job.py`) in your API\n- Indexing Kafka message into Elasticsearch through thread in Restful API: \u003ci\u003ehttps://github.com/euiyounghwang/python-flask-basic/blob/master/job/kafka_job.py#L35\u003c/i\u003e\n- Create message using this shell script `./create-topic-run.sh, ./create-topic-got.sh, ./create-rabbitmq-run.sh, ./create-rabbitmq-got.sh` based on Kafka, Rabbitmq\n\nBased on your specification, Connexion provides the following functionality:\n- Automatic routing to your Python functions\n- Authentication\n- Request validation\n- Parameter parsing and injection\n- Response serialization\n- Response validation\n- A Swagger UI console with live documentation and ‘try it out’ feature\n\n__Waitress__(`pip install waitress`) (\u003ci\u003ehttps://pypi.org/project/waitress/\u003c/i\u003e) is a production-quality pure-Python WSGI server with very acceptable performance. It has no dependencies except ones which live in the Python standard library\n\ndocker exec -it kafka-cluster-kafka-1-1 kafka-topics --bootstrap-server=localhost:9092 --topic test-topic --delete --group Fastapi\nCreated topic test-topic.\n\n#### Install Poerty\n```bash\nhttps://python-poetry.org/docs/?ref=dylancastillo.co#installing-with-the-official-installer\n```\n\n\n#### Using Python Virtual Environment\n```bash\npython -m venv .venv\nsource .venv/bin/activate\n\n# Migrate\nalembic init alembic\nalembic revision -m \"first migrations\"\nalembic upgrade head\n\n\n# new revision add\n$\u003e alembic revision\n$\u003e alembic revision -m \"message\" # add message\n\n# write revistion after detecting the changes from alembic\n$\u003e alembic revision --autogenerate\n$\u003e alembic revision --autogenerate -m \"message\"\n```\n\n\n#### Using Poetry: Create the virtual environment in the same directory as the project and install the dependencies with basic library:\n```bash\npoetry config virtualenvs.in-project true\npoetry init\npoetry add uvicorn\npoetry add pytest\npoetry add \"connexion[swagger-ui]\"\npoetry add \"connexion[flask]\"\npoetry add \"connexion[swagger-ui]\"\n```\n\n\n#### Handling with different user for github when pushing the commit\n```bash\n(.venv) ➜  python-flask-basic git:(master) git push -u origin master\nremote: Permission to euiyounghwang/python-flask-basic.git denied to euiyounghwang1.\nfatal: unable to access 'https://github.com/euiyounghwang/python-flask-basic.git/': The requested URL returned error: 403\n(.venv) ➜  python-flask-basic git:(master) git config --local credential.helper \"\"\n```\n\n#### Run Service\n```bash\nhttp://localhost:5000/api/ui/\n```\n\n\n#### Push Docker-io with my account\n```bash\n\ndocker login -u \"euiyoung\" -p \"\u003cpassword\u003e\" docker.io\n\ndocker push euiyoung/fn-flask-basic-api:es\n\n(.venv) ➜  python-elasticsearch git:(master) docker push euiyoung/fn-flask-basic-api:es\nThe push refers to repository [docker.io/euiyoung/fn-flask-basic-api]\n5d647ec1a1fb: Pushed\nfd06eaaba40d: Pushed\n64affd5054b0: Pushed\n0d9bf610013e: Pushed\nddb6a9981c5b: Pushed\n91f013cc9ad4: Pushed\n1d228a5c814d: Pushed\n96241174affd: Pushed\n174a3bb9cb52: Pushed\nf69e96eb5a0c: Pushed\n44ea9a923069: Pushed\n4b9bc13fb5b2: Pushed\nc9f974dacf48: Pushed\ncdc9dae211b4: Pushed\n7095af798ace: Pushed\nfe6a4fdbedc0: Pushed\ne4d0e810d54a: Pushed\n4e006334a6fd: Pushed\nes: digest: sha256:1154c1125dca43ae585f45af4bf0df9374eecf05ab35d3fb9ac5131e97b0ce22 size: 4101\n```\n\n\n### Swagger for REST-API\n![Alt text](./screenshot/Restful_Swagger.png)\n\n\n\n### Pytest\n- Docker with py.test\n```bash\nfn-flask-basic-api-test\neuiyoung/fn-flask-basic-api:test\n76ff0f2223a2\n15001:5001\n\n2024-01-27 22:23:54 ============================= test session starts ==============================\n2024-01-27 22:23:54 platform linux -- Python 3.6.13, pytest-7.0.1, pluggy-1.0.0 -- /usr/local/bin/python\n2024-01-27 22:23:54 cachedir: .pytest_cache\n2024-01-27 22:23:54 rootdir: /app/FN-BEES-Services/tests, configfile: pytest.ini\n2024-01-27 22:23:54 plugins: cov-4.0.0, mock-3.6.1\n2024-01-27 22:23:54 collecting ... collected 1 item\n2024-01-27 22:23:54 \n2024-01-27 22:23:55 tests/test_api.py::BaseTestAliveController::test_get_restful PASSED      [100%]\n2024-01-27 22:23:55 \n2024-01-27 22:23:55 ============================== 1 passed in 1.05s ===============================\n```\n- Go to virtual enviroment using `source .venv/bin/activate`\n- Run this command manually: `poetry run py.test -v --junitxml=test-reports/junit/pytest.xml --cov-report html --cov tests/` or `./pytest.sh`\n```bash\n(.venv) ➜  python-flask-basic git:(master) ./pytest.sh \n======================================================================== test session starts =========================================================================\nplatform darwin -- Python 3.9.7, pytest-7.0.1, pluggy-1.4.0 -- /Users/euiyoung.hwang/ES/Python_Workspace/python-flask-basic/.venv/bin/python\ncachedir: .pytest_cache\nrootdir: /Users/euiyoung.hwang/ES/Python_Workspace/python-flask-basic/tests, configfile: pytest.ini\nplugins: mock-3.6.1, cov-4.0.0\ncollected 1 item                                                                                                                                                     \n\ntests/test_api.py::BaseTestAliveController::test_get_restful PASSED                                                                                            [100%]\n\n---------- coverage: platform darwin, python 3.9.7-final-0 -----------\nName                               Stmts   Miss  Cover   Missing\n----------------------------------------------------------------\napi/__init__.py                       42      1    98%   58\napi/controller/__init__.py             0      0   100%\napi/controller/api_controller.py      48     31    35%   20-23, 28-39, 44-52, 56-64\napi/repository/__init__.py             0      0   100%\napi/repository/model.py               10      0   100%\napi/repository/repo.py                43     27    37%   13-18, 21-26, 37-44, 47-53, 56-58\napi/repository/schema.py               6      0   100%\nconfig/__init__.py                     0      0   100%\nconfig/log_config.py                  32      1    97%   42\ntests/__init__.py                     12      1    92%   16\ntests/conftest.py                     16      8    50%   10-13, 19-24\ntests/test_api.py                     10      1    90%   16\n----------------------------------------------------------------\nTOTAL                                219     70    68%                                            [100%]\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feuiyounghwang%2Fpython-flask-basic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feuiyounghwang%2Fpython-flask-basic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feuiyounghwang%2Fpython-flask-basic/lists"}