S allius/issue378 (#382)
* move home route into web diretory * add web UI to add-on * update changelog * use Blueprints
This commit is contained in:
@@ -15,6 +15,7 @@ from cnf.config import Config
|
||||
from cnf.config_read_env import ConfigReadEnv
|
||||
from cnf.config_read_toml import ConfigReadToml
|
||||
from cnf.config_read_json import ConfigReadJson
|
||||
from web.routes import web_routes
|
||||
from modbus_tcp import ModbusTcp
|
||||
|
||||
|
||||
@@ -31,11 +32,7 @@ class ProxyState:
|
||||
|
||||
|
||||
app = Quart(__name__)
|
||||
|
||||
|
||||
@app.route('/')
|
||||
async def hello():
|
||||
return Response(response="Hello, world")
|
||||
app.register_blueprint(web_routes)
|
||||
|
||||
|
||||
@app.route('/-/ready')
|
||||
|
||||
9
app/src/web/routes.py
Normal file
9
app/src/web/routes.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from quart import Blueprint
|
||||
from quart import Response
|
||||
|
||||
web_routes = Blueprint('web_routes', __name__)
|
||||
|
||||
|
||||
@web_routes.route('/')
|
||||
async def hello():
|
||||
return Response(response="Hello, world")
|
||||
@@ -33,16 +33,6 @@ def test_get_log_level():
|
||||
log_lvl = get_log_level()
|
||||
assert log_lvl == None
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_home():
|
||||
"""Test the home route."""
|
||||
client = app.test_client()
|
||||
response = await client.get('/')
|
||||
assert response.status_code == 200
|
||||
result = await response.get_data()
|
||||
assert result == b"Hello, world"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_ready():
|
||||
"""Test the ready route."""
|
||||
|
||||
15
app/tests/test_web_route.py
Normal file
15
app/tests/test_web_route.py
Normal file
@@ -0,0 +1,15 @@
|
||||
# test_with_pytest.py
|
||||
import pytest
|
||||
from server import app
|
||||
|
||||
pytest_plugins = ('pytest_asyncio',)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_home():
|
||||
"""Test the home route."""
|
||||
client = app.test_client()
|
||||
response = await client.get('/')
|
||||
assert response.status_code == 200
|
||||
result = await response.get_data()
|
||||
assert result == b"Hello, world"
|
||||
Reference in New Issue
Block a user