{"id":16408682,"url":"https://github.com/m4n3dw0lf/flask-lxc","last_synced_at":"2025-10-26T17:32:12.762Z","repository":{"id":57430468,"uuid":"134925360","full_name":"m4n3dw0lf/flask-lxc","owner":"m4n3dw0lf","description":"Flask LXC API Blueprint","archived":false,"fork":false,"pushed_at":"2018-06-02T02:09:12.000Z","size":23,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-31T22:06:20.574Z","etag":null,"topics":["flask-api","flask-application","flask-blueprints","lxc","lxc-containers"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/m4n3dw0lf.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":"2018-05-26T03:19:02.000Z","updated_at":"2023-06-09T19:34:37.000Z","dependencies_parsed_at":"2022-08-26T05:02:04.416Z","dependency_job_id":null,"html_url":"https://github.com/m4n3dw0lf/flask-lxc","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m4n3dw0lf%2Fflask-lxc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m4n3dw0lf%2Fflask-lxc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m4n3dw0lf%2Fflask-lxc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m4n3dw0lf%2Fflask-lxc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/m4n3dw0lf","download_url":"https://codeload.github.com/m4n3dw0lf/flask-lxc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238375318,"owners_count":19461580,"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":["flask-api","flask-application","flask-blueprints","lxc","lxc-containers"],"created_at":"2024-10-11T06:17:32.264Z","updated_at":"2025-10-26T17:32:07.476Z","avatar_url":"https://github.com/m4n3dw0lf.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flask LXC API Blueprint \n\n\u003cbr\u003e\n\n## Installing locally\n\n### Install LXC\n\n- Debian 9 (Jessie) Setup\n\n```\nsudo apt-get install -y lxc python-lxc\n\necho 'USE_LXC_BRIDGE=\"true\"' | sudo tee /etc/default/lxc-net\n\nsudo bash -c 'cat \u003c\u003c EOF \u003e /etc/lxc/default.conf\nlxc.network.type = veth\nlxc.network.link = lxcbr0\nlxc.network.flags = up\nlxc.network.hwaddr = 00:16:3e:a1:b2:c3\nEOF'\n\nsudo service lxc-net restart\n```\n\n## Running locally\n\n```\ngit clone https://github.com/m4n3dw0lf/flask-lxc\nsudo pip install -r requirements.txt\nsudo python run.py\n```\n\n## Running as docker container\n\n\u003e Need to run as **root** user\n\n```\ndocker pull m4n3dw0lf/flask_lxc\ndocker run -it --net=host --rm --privileged --name test m4n3dw0lf/flask_lxc\n```\n\n## Importing as blueprint on your flask app\n\n- install the package\n\n```\npip install flask_lxc\n```\n\n- register the blueprint\n\n```\nfrom flask import Flask\nfrom flask_lxc import lxc_api\n\n# Can be your own app\napp = Flask(__name__)\napp.register_blueprint(lxc_api)\n```\n\n\u003cbr\u003e\u003cbr\u003e\n\n## API\n\n### Create new LXC Container\n\nsyntax:\n\n```\ncurl -X POST \\\nhttp://localhost:5000/lxc/create/\u003cCONTAINER\u003e \\\n-H \"Content-Type:application/json\" \\\n-d '{\n \"image\":\"\u003cIMAGE\u003e\",\n \"args\":{\n   \"release\":\"\u003cRELEASE\u003e\",\n   \"arch\":\"\u003cARCH\u003e\"\n }\n}'\n```\n\nexample:\n\n```\ncurl -X POST \\\nhttp://localhost:5000/lxc/create/debian1 \\\n-H \"Content-Type:application/json\" \\\n-d '{\n \"image\":\"debian\",\n \"args\":{\n   \"release\":\"jessie\",\n   \"arch\":\"amd64\"\n }\n}'\n```\n\n\u003cbr\u003e\n\n### List LXC Containers\n\nsyntax:\n\n`curl http://localhost:5000/lxc/list`\n\n\u003cbr\u003e\n\n### Start LXC Container\n\nsyntax:\n\n`curl http://localhost:5000/lxc/start/\u003cCONTAINER_NAME\u003e`\n\nexample:\n\n`curl http://localhost:5000/lxc/start/debian1`\n\n\u003cbr\u003e\n\n### Stop LXC Container\n\nsyntax:\n\n`curl http://localhost:5000/lxc/stop/\u003cCONTAINER_NAME\u003e`\n\nexample:\n\n`curl http://localhost:5000/lxc/stop/debian1`\n\n\u003cbr\u003e\n\n### Destroy LXC Container\n\nsyntax:\n\n`curl http://localhost:5000/lxc/destroy/\u003cCONTAINER_NAME\u003e`\n\nexample:\n\n`curl http://localhost:5000/lxc/destroy/debian1`\n\n\u003cbr\u003e\n\n### Expose port of the container\n\nsyntax:\n\n```\ncurl -X POST \\\nhttp://localhost:5000/lxc/expose/\u003cCONTAINER_NAME\u003e \\\n-H \"Content-Type:application/json\" \\\n-d '{\n  \"sport\":\"\u003cPORT_TO_EXPOSE\u003e\",\n  \"dport\":\"\u003cCONTAINER_PORT\u003e\",\n  \"protocol\":\"\u003cPROTOCOL\u003e\"\n}'\n```\n\nexample:\n\n```\ncurl -X POST \\\nhttp://localhost:5000/lxc/expose/debian1 \\\n-H \"Content-Type:application/json\" \\\n-d '{\n  \"sport\":\"80\",\n  \"dport\":\"80\",\n  \"protocol\":\"tcp\"\n}'\n```\n\n### Get config keys\n\nsyntax:\n\n`curl http://localhost:5000/lxc/config/\u003cCONTAINER\u003e`\n\nexample:\n\n`curl http://localhost:5000/lxc/config/debian1`\n\n### Set config keys\n\nsyntax:\n```\ncurl -X POST \\\nhttp://localhost:5000/lxc/config/\u003cCONTAINER\u003e \\\n-H \"Content-Type:application/json\" \\\n-d '{\n  \"\u003cKEY\u003e\":\"\u003cVALUE\u003e\"\n}'\n```\n\nexample:\n\n```\ncurl -X POST \\\nhttp://localhost:5000/lxc/config/debian1 \\\n-H \"Content-Type:application/json\" \\\n-d '{\n  \"lxc.network\":\"veth\"\n}'\n```\n\n\u003cbr\u003e\u003cbr\u003e\n\n## Reference\n\nInstructions to setup LXC and LXC Networking for Debian Jessie\n\n- https://wiki.debian.org/LXC\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm4n3dw0lf%2Fflask-lxc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fm4n3dw0lf%2Fflask-lxc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm4n3dw0lf%2Fflask-lxc/lists"}