{"id":24659099,"url":"https://github.com/raynardj/flaskonf","last_synced_at":"2026-04-18T09:38:40.241Z","repository":{"id":57430548,"uuid":"324948236","full_name":"raynardj/flaskonf","owner":"raynardj","description":"Configuration Driven API","archived":false,"fork":false,"pushed_at":"2021-05-08T09:13:47.000Z","size":1182,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-27T05:16:11.799Z","etag":null,"topics":["api","configuration","flask","python"],"latest_commit_sha":null,"homepage":"https://raynardj.github.io/flaskonf/","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/raynardj.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-12-28T07:54:58.000Z","updated_at":"2021-05-08T09:16:29.000Z","dependencies_parsed_at":"2022-08-27T22:11:51.354Z","dependency_job_id":null,"html_url":"https://github.com/raynardj/flaskonf","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raynardj%2Fflaskonf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raynardj%2Fflaskonf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raynardj%2Fflaskonf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raynardj%2Fflaskonf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raynardj","download_url":"https://codeload.github.com/raynardj/flaskonf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244744206,"owners_count":20502867,"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","configuration","flask","python"],"created_at":"2025-01-26T02:31:50.025Z","updated_at":"2026-04-18T09:38:35.071Z","avatar_url":"https://github.com/raynardj.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flaskonf\n\u003e Configuration Driven API\n\n\n## Installation\n\nUnder your python environment\n\n```shell\npip install flaskonf\n```\n\n## Create API with configuration json files\n\nSuppose you have configuration files like following\n\n```python\n!ls ../tests/confs/\n```\n\n    la.json       shanghai.json\n\n\n```python\n!cat ../tests/confs/*.json\n```\n\n    {\n        \"name\":\"Los Angeles\",\n        \"country\":\"United States\",\n        \"sites\":[\"universal studio\", \"griffith observatory\", \"union station\"]\n    }\n    {\n        \"name\":\"Shanghai\",\n        \"country\":\"China\",\n        \"sites\":[\"french concession\", \"xin tiandi\", \"disney resort\"]\n    }\n\n\n```python\nfrom flaskonf.api import FlaskonfAPI\nfrom typing import Dict\n```\n\n```python\napp = FlaskonfAPI(\"AnConfAPI\")\n```\n\nBind the app to the configuration directory\n\nExample directory is for test inputs example, you can just leave it empety for now\n\n```python\napp.build_on_config(\n    confs_dir=\"../tests/confs/\",\n    examples_dir=\"../tests/examples/\" )\n```\n\n### Create API blueprint\n\nThe syntax looks like creating API, but this is a blueprint based on what we will create an **API for each json file**\n\n```python\n@app.conf_route(\"/guide/\", nobuild=True)\ndef guide_api(inputs: Dict):\n    data = inputs['data']\n    conf = data[\"conf\"]\n    user = data[\"user\"]\n    return {\"city_data\": conf, \"user\": user}\n\napp.build_flaskonf()\n```\n\nNotice, the configuration data is accessible in the decorated function\n\nThe rest is flask usual you are familiared with, if you run like following, you can visit ```localhost:6060/guide/la/``` or ```localhost:6060/guide/shanghai/``` to test your API\n\n```python\napp.run(\"0.0.0.0\", port = 6060)\n```\n\n     * Serving Flask app \"AnConfAPI\" (lazy loading)\n     * Environment: production\n       WARNING: This is a development server. Do not use it in a production deployment.\n       Use a production WSGI server instead.\n     * Debug mode: off\n\n\n     * Running on http://0.0.0.0:6060/ (Press CTRL+C to quit)\n    INFO:werkzeug: * Running on http://0.0.0.0:6060/ (Press CTRL+C to quit)\n\n\n## When loading API components takes effort\n\u003e eg. when you have to load huge AI model into memory when starting the server\n\nSet ```nobuild=True```\n\n```python\n@app.conf_route(\"/guide2/\", nobuild=False)\ndef build_city_guide(conf_file: str, conf: Dict):\n    logging.info(f\"{conf}\")\n    # doing other things for building API here\n    # like load huge model into memory with configuration\n    def guide_api(inputs: Dict):\n        data = inputs['data']\n        user = data[\"user\"]\n        return {\"city_data\": conf, \"user\": user}\n    return guide_api\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraynardj%2Fflaskonf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraynardj%2Fflaskonf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraynardj%2Fflaskonf/lists"}