-
Notifications
You must be signed in to change notification settings - Fork 76
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
7 changed files
with
36 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from web._server import run_webserver |
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,30 @@ | ||
import time | ||
from pathlib import Path | ||
|
||
import fastapi.responses | ||
import uvicorn | ||
from fastapi import FastAPI | ||
from fastapi.staticfiles import StaticFiles | ||
from starlette import status | ||
from starlette.responses import FileResponse | ||
|
||
|
||
def run_webserver(): | ||
openwb_root = Path(__file__).parents[2] | ||
|
||
app = FastAPI() | ||
|
||
@app.get("/") | ||
async def root(): | ||
return fastapi.responses.RedirectResponse("/web/", status.HTTP_303_SEE_OTHER) | ||
|
||
@app.get("/web/") | ||
async def web_root(): | ||
return FileResponse(openwb_root.joinpath("web", "themes", "standard", "theme.html")) | ||
|
||
@app.get("/sample") | ||
async def sample(): | ||
return f"Hello world! Time is {time.time()}" | ||
|
||
app.mount("/web", StaticFiles(directory=openwb_root / "web", html=True), name="static") | ||
uvicorn.run(app, host="0.0.0.0", port=80) |
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 |
---|---|---|
|
@@ -3,3 +3,5 @@ paho_mqtt==1.6.1 | |
pymodbus==2.5.2 | ||
pytest==6.2.5 | ||
requests_mock==1.9.3 | ||
fastapi==0.70.1 | ||
uvicorn==0.16.0 |
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
File renamed without changes.