[app] create the main API routes and mount the routers
This commit is contained in:
parent
27c329e4f5
commit
a77428547b
2 changed files with 57 additions and 4 deletions
|
|
@ -1,10 +1,24 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from starlette.routing import Router
|
||||
from starlette.mounting import Mount
|
||||
from starlette.routing import Router, Mount, Route
|
||||
from starlette.responses import HTMLResponse
|
||||
from starlette.exceptions import HTTPException
|
||||
|
||||
app = Router(routes=[
|
||||
from pyheatpump.config import config
|
||||
from pyheatpump.heatpump import app as heatpump
|
||||
from pyheatpump.variable_types import app as types
|
||||
from pyheatpump.variables import app as variables
|
||||
from pyheatpump.variable_values import app as values
|
||||
|
||||
async def index(request):
|
||||
with open('index.html') as html:
|
||||
return HTMLResponse(html.read())
|
||||
raise HTTPException(404)
|
||||
|
||||
application = Router(routes=[
|
||||
Route('/', index),
|
||||
Mount('/heatpump', heatpump),
|
||||
Mount('/config', config),
|
||||
Mount('/heatpump', heatpump),
|
||||
Mount('/variables', types),
|
||||
Mount('/values', values)
|
||||
])
|
||||
|
|
|
|||
39
pyheatpump/index.html
Normal file
39
pyheatpump/index.html
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>pyHeatpump API index</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>pyHeatpump API</h1>
|
||||
<p>
|
||||
Welcome to the pyHeatpump API.
|
||||
</p>
|
||||
<hr />
|
||||
<h2>Routes</h2>
|
||||
<p>
|
||||
List of the GET routes.
|
||||
|
||||
<i>All of these routes return JSON-formatted dictionaries.</i>
|
||||
</p>
|
||||
|
||||
<h3>Heatpump</h3>
|
||||
<ul>
|
||||
<li><a href="/heatpump">/heatpump</a> Get all variable values of a heatpump</li>
|
||||
</ul>
|
||||
<h3>Variable types</h3>
|
||||
<ul>
|
||||
<li><a href="/types">/types</a> Get all variable types</li>
|
||||
</ul>
|
||||
<h3>Variables</h3>
|
||||
<ul>
|
||||
<li><a href="/variables">/variables</a> Get all variables</li>
|
||||
</ul>
|
||||
<h3>Variables values</h3>
|
||||
<ul>
|
||||
<li><a href="/values">/values</a> Get all variables (not implemented)</li>
|
||||
<li><a href="/values/A/1">/values/{TYPE}/{ADDRESS}</a> Get current variable value</li>
|
||||
<li><a href="/values/A/1/2020-08-02T13:21:42">/values/{TYPE}/{ADDRESS}/{TIMESTAMP}</a> Get variable value at specified time (in iso format, e.g. : 2020-08-02T13:21:42)</li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue