-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
121 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import logging | ||
|
||
def list_access_points(): | ||
return {"ssids": [{"ssid": "my_wifi"}]} | ||
|
||
def connection_status(): | ||
return {"wifi": "true", "internet": "true"} | ||
|
||
def connect(): | ||
return "ok" | ||
|
||
def forget(): | ||
return "ok" | ||
|
||
def sset_hotspot_ssid(): | ||
return "ok" | ||
|
||
def set_hotspot_password(): | ||
return "ok" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/python | ||
|
||
import os | ||
import logging | ||
import logging.handlers | ||
import connexion | ||
from connexion.middleware import MiddlewarePosition | ||
from starlette.middleware.cors import CORSMiddleware | ||
|
||
# Logging configuration | ||
logger = logging.getLogger() | ||
logger.setLevel(os.environ.get("LOGLEVEL", "INFO")) | ||
|
||
## (Connexion) Flask app configuration | ||
|
||
# Serve a custom version of the swagger ui (Jinja2 templates) based on the default one | ||
# from the folder 'swagger-ui'. Clone the 'swagger-ui' repository inside the backend folder | ||
|
||
app = connexion.App(__name__) | ||
app.add_middleware( | ||
CORSMiddleware, | ||
position=MiddlewarePosition.BEFORE_EXCEPTION, | ||
allow_origins=["*"], | ||
allow_credentials=True, | ||
allow_methods=["*"], | ||
allow_headers=["*"], | ||
) | ||
|
||
## New API and web application | ||
|
||
# API v1 is defined in v1.yml and its methods are in api.py | ||
app.add_api('v1.yml') | ||
|
||
if __name__ == "__main__": | ||
app.run(host="0.0.0.0", port=9090) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
openapi: "3.0.0" | ||
info: | ||
version: "1.0" | ||
title: OpenAPI 3.0 definition of WiFi API | ||
|
||
servers: | ||
- url: http://coderbot.local/v1 | ||
|
||
# Paths supported by the server application | ||
paths: | ||
/list_access_points: | ||
get: | ||
operationId: "api.list_access_points" | ||
summary: "list Access Points" | ||
responses: | ||
200: | ||
description: "ok" | ||
tags: | ||
- Wifi | ||
/connection_status: | ||
get: | ||
operationId: "api.connection_status" | ||
summary: "connection Status" | ||
responses: | ||
200: | ||
description: "ok" | ||
tags: | ||
- Wifi | ||
/connect: | ||
post: | ||
operationId: "api.connect" | ||
summary: "connect" | ||
responses: | ||
200: | ||
description: "ok" | ||
tags: | ||
- Wifi | ||
/forget: | ||
post: | ||
operationId: "api.forget" | ||
summary: "forget" | ||
responses: | ||
200: | ||
description: "ok" | ||
tags: | ||
- Wifi | ||
/sset_hotspot_ssid: | ||
post: | ||
operationId: "api.sset_hotspot_ssid" | ||
summary: "sset_hotspot_ssid" | ||
responses: | ||
200: | ||
description: "ok" | ||
tags: | ||
- Wifi | ||
/set_hotspot_password: | ||
post: | ||
operationId: "api.set_hotspot_password" | ||
summary: "set_hotspot_password" | ||
responses: | ||
200: | ||
description: "ok" | ||
tags: | ||
- Wifi |