API server and examples
This commit is contained in:
parent
8fe9babfca
commit
7a4bc92969
|
@ -6,7 +6,7 @@ packages:
|
||||||
- libffi-dev
|
- libffi-dev
|
||||||
- openssl-dev
|
- openssl-dev
|
||||||
sources:
|
sources:
|
||||||
- https://git.sr.ht/~fmartingr/jeeves
|
- https://code.fmartingr.com/fmartingr/jeeves
|
||||||
tasks:
|
tasks:
|
||||||
- setup: |
|
- setup: |
|
||||||
pip install poetry
|
pip install poetry
|
||||||
|
|
|
@ -9,7 +9,7 @@ source code and be able to run it in your local machine.
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
git clone git@git.sr.ht:~fmartingr/jeeves
|
git clone git@code.fmartingr.com:fmartingr/jeeves
|
||||||
|
|
||||||
|
|
||||||
In this project we use Poetry_ to manage
|
In this project we use Poetry_ to manage
|
||||||
|
|
|
@ -9,7 +9,7 @@ need to clone the repository or download a release manually.
|
||||||
|
|
||||||
.. code-block::
|
.. code-block::
|
||||||
|
|
||||||
git clone git@git.sr.ht:~fmartingr/jeeves
|
git clone git@code.fmartingr.com:fmartingr/jeeves
|
||||||
cd jeeves
|
cd jeeves
|
||||||
poetry install
|
poetry install
|
||||||
poetry run jeeves --help
|
poetry run jeeves --help
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
from jeeves.server.app import app
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app.run(debug=True)
|
|
@ -0,0 +1,41 @@
|
||||||
|
import os
|
||||||
|
|
||||||
|
from quart import Quart, redirect, request, jsonify
|
||||||
|
import jinja2
|
||||||
|
|
||||||
|
from jeeves.core.parsers import FlowParser
|
||||||
|
|
||||||
|
app = Quart(__name__)
|
||||||
|
jinja2_env = jinja2.Environment(loader=jinja2.FileSystemLoader("/home/fmartingr/Code/jeeves/jeeves/server/frontend/templates"))
|
||||||
|
|
||||||
|
|
||||||
|
FLOWS = []
|
||||||
|
DATA_FOLDER = "~/Code/jeeves/_data"
|
||||||
|
for rootname, dirnames, filenames in os.walk(DATA_FOLDER):
|
||||||
|
for filename in filenames:
|
||||||
|
_zz, extension = os.path.splitext(os.path.join(rootname, filename))
|
||||||
|
if extension == '.yaml':
|
||||||
|
FLOWS.append(FlowParser.from_yaml(open(os.path.join(rootname, filename), "rb").read()))
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/healthz")
|
||||||
|
async def healthz_view():
|
||||||
|
return "ok"
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/")
|
||||||
|
async def home():
|
||||||
|
return redirect("/flows")
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/flows")
|
||||||
|
async def list_flows():
|
||||||
|
template = jinja2_env.get_template("flows/list.j2")
|
||||||
|
return template.render(flows=FLOWS)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/flows/<int:flow_id>")
|
||||||
|
async def flow_detail(flow_id):
|
||||||
|
flow = list(filter(lambda flow: flow.id == flow_id, FLOWS))[0]
|
||||||
|
template = jinja2_env.get_template("flows/task-list.j2")
|
||||||
|
return template.render(flow=flow)
|
|
@ -0,0 +1,17 @@
|
||||||
|
name: Build Synology-Drive AUR package
|
||||||
|
id: 123
|
||||||
|
tasks:
|
||||||
|
- name: Perform a curl command
|
||||||
|
type: contrib/script
|
||||||
|
parameters:
|
||||||
|
script: curl fmartingr.com
|
||||||
|
|
||||||
|
- name: Generate an output file (use `-a` flag with execute command)
|
||||||
|
type: contrib/template
|
||||||
|
parameters:
|
||||||
|
src: template.j2
|
||||||
|
dest: output.txt
|
||||||
|
|
||||||
|
arguments:
|
||||||
|
- name: variable
|
||||||
|
required: true
|
|
@ -0,0 +1 @@
|
||||||
|
Hello {{ variable }}
|
Reference in New Issue