Skip to content

Commit

Permalink
api doc is now flask
Browse files Browse the repository at this point in the history
  • Loading branch information
gummyfrog committed May 6, 2024
1 parent 1c0ce4d commit b6178e1
Showing 1 changed file with 139 additions and 46 deletions.
185 changes: 139 additions & 46 deletions documentation/docs/api-specification/BlastPadAPIDoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,65 +4,158 @@ sidebar_position: 1

# BlastPad

(generated using [Sphinx](../../../build/html/index.html))
<!-- (generated using [Sphinx](../../../build/html/index.html)) -->

# API Documentation

## Wireless Manager API
This document describes the API endpoints available from the Flask server.

### `scan_wifi_networks()`

Scans for available Wi-Fi networks on the 'wlan0' network interface.
### `GET /editor`
<details open="True">
- Renders the Blockly editor.
- Optional Parameters:
- fromHomescreen: Makes the "Return to Home" button visible if true.
- game: Tries to load a specific game workspace if present.
</details>

### `GET /`
<details open="True">
- Renders the Home Screen.
</details>

### `GET /icons/<path>`
<details open="True">
- Returns a saved game icon from the `/icons` folder.
</details>

### `POST /save>`
<details open="True">
- Attempts to save, compile, and test run a workspace.
- Expected Body: A Game Workspace
</details>

### `POST /saveWithoutRun>`
<details open="True">
- Attempts to save and compile a workspace.
- Expected Body: A Game Workspace
</details>

#### Usage:
### `GET /games`
<details open="True">
- Returns an array of metadata describing locally saved games.
</details>

`result = subprocess.run(
['iw', 'dev', 'wlan0', 'scan'], capture_output=True, text=True)`

#### Returns:
### `GET /games/<game_workspace_filename>`
<details open="True">
- Returns the full JSON workspace of the specified game.
</details>

Command-Line response
`result.stdout`

### `list_wifi_networks()`
### `GET /run`
<details open="True">
- Attempts to compile and run a game.
- Expected Parameters:
- game: Name of the game to run.
</details>


### `GET /compile`
<details open="True">
- Attempts to compile a game.
- Expected Parameters:
- game: Name of the game to compile.
</details>

### `GET /test`
<details open="True">
- Attempts to run a game for 5 seconds in the background.
- Expected Parameters:
- game: Name of the game to compile.
</details>

### `GET /get_wifi_networks`
<details open="True">
- Returns available local access points.
</details>


### `POST /disconnect_wifi`
<details open="True">
- Disconnects from the current access point.
</details>


### `POST /connect_to_wifi`
<details open="True">
- Attempts to connect to a specified access point.
- Body:
- SSID: SSID of the desired access point.
- Password: Password for the desired access point.
</details>


### `GET /get/community/<search>`
<details open="True">
- Returns game metadata from Supabase where game names fuzzy-match `<search>`.
- Defaults to all games if `<search>` is not present.
</details>

### `GET /get/classroom/<classroom_id>/<search>`
<details open="True">
- Returns game metadata from Supabase where game names belong to `<classroom_id>` and fuzzy-match `<search>`.
- Defaults to all games belonging to `<classroom_id>` if `<search>` is not present.
</details>


### `POST /create/classroom`
<details open="True">
- Creates a classroom based on the body of the request.
- Body:
- Classroom Data
- invite_code: String
- teacher: String
- title: String
- description: String
</details>



### `GET /share/community/<game_name>`
<details open="True">
- Shares a game called `<game_name>` to the community hub.
</details>


### `GET /share/classroom/<classroom_id>/<game_name>`
<details open="True">
- Shares a game called `<game_name>` to the classroom matching `<classroom_id>`.
</details>

Lists the SSIDs of available Wi-Fi networks.
### `GET /join/classroom/<invite>`
<details open="True">
- Joins a classroom with the invite code `<invite>`
</details>

#### Usage:

`scan_result = wirelessManager.scan_wifi_networks()
networks = re.findall(r'SSID: (.+)', scan_result)`
### `GET /leave/classroom/<invite>`
<details open="True">
- Leaves a classroom with the invite code `<invite>`
</details>

#### Returns:

list of available networks
### `GET /download/community/<game_name>`
<details open="True">
- Downloads a game from the community hub matching `<game_name>`.
</details>

### `connect_to_wifi(ssid, password=None)`

Connects to a Wi-Fi network with the specified SSID and optional password.

#### Usage:

`wirelessManager.connect_to_wifi('SSID', 'password')`

### `disconnect_wifi()`

Disconnects from the currently connected Wi-Fi network.

#### Usage:

`wirelessManager.disconnect_wifi()`

### `show_wifi_security(ssid)`

Shows the type of Wi-Fi security on a network.

#### Usage:

`result = subprocess.run(
['iw', 'dev', 'wlan0', 'scan', 'essid', 'SSID'], capture_output=True, text=True)
security_info = re.search(r'WPA2?-(?:PSK|EAP)', result.stdout)`

#### Returns:

`Security Info Type or "Security information not available."`
### `GET /download/classroom/<classroom_id>/<game_name>`
<details open="True">
- Downloads a game from the classroom with id `<classroom_id>` matching `<game_name>`.
</details>

### `GET /running`
<details open="True">
- Returns `{"success": "successful!}`.
</details>

0 comments on commit b6178e1

Please sign in to comment.