Skip to content

Commit e78152c

Browse files
committed
Merge branch 'develop' of https://github.com/CoderBotOrg/coderbot into develop
2 parents 35fc332 + 79da25a commit e78152c

File tree

4 files changed

+57
-8
lines changed

4 files changed

+57
-8
lines changed

README.md

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,30 @@
1-
CoderBot
2-
========
1+
# CoderBot
32

4-
A RaspberryPI-based bot controller
3+
A RaspberryPI-based programmable robot for educational purposes. Check the [project website](https://coderbot.org) for more information.
54

6-
The module provide a simple web interface to a raspberry py "robot".
5+
For further information about development and technical documentation, see the [Wiki](https://github.com/CoderBotOrg/coderbot/wiki).
76

8-
See the [wiki](https://github.com/CoderBotOrg/coderbot/wiki) for the documentation
7+
This repository contains the backend, along with some configuration applied on the base system image.
98

9+
### Quickstart
1010

11+
```bash
12+
git clone https://github.com/CoderBotOrg/coderbot.git
13+
cd coderbot
14+
python3 -m venv .
15+
source bin/activate
16+
pip3 install -r requirements.txt
17+
18+
# Start the backend in stub mode
19+
PYTHONPATH=stub python3 init.py
20+
21+
# or, run the real thing if you're on a physical RPi
22+
python3 init.py
23+
```
24+
25+
The legacy API and frontend application is available at `localhost:5000`.
26+
27+
The new API is at `localhost:5000/v2`, while the new application is served at `localhost:5000/vue` (assuming the [vue-app](https://github.com/coderbotorg/vue-app) build is placed in the `dist/` folder).
28+
29+
To see the dynamic documentation of the new API, clone the [swagger-ui](https://github.com/coderbotorg/swagger-ui) repository inside the `coderbot/` folder and it'll be live at `localhost:5000/v2/ui/index.html`.
1130

api.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,19 @@ def turn(data):
3232
def status():
3333
return "ok"
3434

35+
def list(data):
36+
return json.dumps(prog_engine.prog_list())
37+
3538
def exec(data):
3639
prog = prog_engine.create(data["name"], data["code"])
3740
return json.dumps(prog.execute())
3841

3942
def save(data):
4043
prog = Program(data["name"], data["code"], data["dom_code"])
4144
prog_engine.save(prog)
42-
return "ok"
45+
return "ok"
46+
47+
def load(data):
48+
prog = prog_engine.load(data["id"])
49+
return jsonify(prog.as_json())
50+

main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@
5656
connexionApp = connexion.App(__name__, swagger_ui=True, swagger_path='swagger-ui/')
5757
# We serve a custom version of the swagger ui (Jinja2 templates) based on the default one
5858

59-
# New API is defined in swagger.yml and api.py
60-
connexionApp.add_api('swagger.yml')
59+
# New API is defined in v2.yml and its methods are in api.py
60+
connexionApp.add_api('v2.yml')
6161

6262

6363
# Connexion wraps FlaskApp, so app becomes app

swagger.yml renamed to v2.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,30 @@ basePath: "/v2"
1212

1313
# Paths supported by the server application
1414
paths:
15+
/list:
16+
get:
17+
operationId: "api.list"
18+
summary: "Get the list of all the saved programs"
19+
tags:
20+
- Program management
21+
responses:
22+
200:
23+
description: "ok"
24+
/load:
25+
get:
26+
operationId: "api.load"
27+
summary: "Get the program with the specified ID"
28+
tags:
29+
- Program management
30+
responses:
31+
200:
32+
description: "ok"
1533
/save:
1634
post:
1735
operationId: "api.save"
1836
summary: "Save a new program"
37+
tags:
38+
- Program management
1939
parameters:
2040
- in: body
2141
name: data
@@ -28,6 +48,8 @@ paths:
2848
post:
2949
operationId: "api.exec"
3050
summary: "Execute the given program"
51+
tags:
52+
- Program management
3153
parameters:
3254
- in: body
3355
name: data

0 commit comments

Comments
 (0)