Skip to content

Commit

Permalink
added basic webserver functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
XilefTech committed Oct 23, 2020
1 parent 541cb58 commit c6175a0
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"files.eol": "\n",
"debug.openDebug": "neverOpen",
"python.linting.enabled": false,
"ev3devBrowser.download.exclude": "{*.md,TODO,LICENSE,.github/*,.vscode/*,.gitignore}"
"ev3devBrowser.download.exclude": "{*.md,TODO,LICENSE,.github/*,.vscode/*,.gitignore,assets/*}"
}
25 changes: 14 additions & 11 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,21 @@
from pybricks.tools import print, StopWatch
from charlieosx import CharlieOSX

### things, I'm sometimes using to test things - can be ignored
"""
lineMap = {'height' : 300, 'width' : 1000,
'from' : (1, 1), 'to' : (1, 4),
'obstacles' : [((2, 1), (4, 1))]}
# os = CharlieOSX('config.cfg', 'settings.json', '')

tools.doIntersect(lineMap)"""


### example code to start CharlieOSX and it's menu-system
os = CharlieOSX('config.cfg', 'settings.json', '')
os.ui.mainLoop()
import picoweb

### example for driving straight
os.robot.straight(100, 20, 0)
app = picoweb.WebApp("app")

@app.route("/")
def index(req, resp):
yield from picoweb.start_response(resp, content_type = "text/html")

htmlFile = open('site.html', 'r')

for line in htmlFile:
yield from resp.awrite(line)

app.run(debug=True, host = "192.168.178.52")
22 changes: 22 additions & 0 deletions site.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<table>
<tr>
<th>sensor</th>
<th>value</th>
<th>timestamp</th>
</tr>
<tr>
<td>temperature</td>
<td>10</td>
<td>10:00</td>
</tr>
<tr>
<td>temperature</td>
<td>11</td>
<td>11:00</td>
</tr>
<tr>
<td>luminosity</td>
<td>11</td>
<td>11:00</td>
</tr>
</table>

0 comments on commit c6175a0

Please sign in to comment.