Skip to content

Latest commit

 

History

History
60 lines (50 loc) · 1.96 KB

index.asciidoc

File metadata and controls

60 lines (50 loc) · 1.96 KB

Create a CRUD Python Flask application using CobiGen’s OpenAPI plugin

The code will be generated using devonfw’s CobiGen. This will result in a basic application layout, the declaration of a Flask-SQLAlchemy table with the entity’s attributes as columns, and a service returning JSON objects for the GET, POST, PUT and DELETE methods.

installDevonfwIde(["java","mvn"]) installCobiGen() executeCommand("devon","devon")

adaptTemplatesCobiGen() changeWorkspace(".cobigen/templates/CobiGen_Templates/src/main/templates") cloneRepository("", "https://github.com/devonfw-forge/cobigen-python-templates.git")

changeFile("context.xml", { "file": "files/context.xml"})

executeCommand("cd /root/devonfw/workspaces/main","cd /root/devonfw/workspaces/main") changeWorkspace("devonfw/workspaces/main") createFile("cobigen-python-example/user.yml", "files/user.yml")

executeCommand("cobigen generate user.yml -i 1","cobigen generate user.yml -i 1",{"dir":"cobigen-python-example"})

executeCommand("python3 -m pip install virtualenv","python3 -m pip install virtualenv") executeCommand("python3 -m virtualenv venv","python3 -m virtualenv venv") executeCommand("activate.ps1","source activate", {"dir":"venv/bin"} ) executeCommand("cd /root/devonfw/workspaces/main/cobigen-python-example","cd /root/devonfw/workspaces/main/cobigen-python-example") executeCommand("pip install -r requirements.txt","pip install -r requirements.txt")

executeCommand("flask db init","flask db init") displayContent("Initial commit", [{ "file": "files/initialCommit.md" }]) executeCommand("flask db upgrade","flask db upgrade")

executeCommand("flask run --host=0.0.0.0 --port=80","flask run --host=0.0.0.0 --port=80") displayContent("Postman test", [{ "file": "files/postmanTest.md" }])