|
20 | 20 | import busio
|
21 | 21 | import digitalio
|
22 | 22 | import neopixel
|
23 |
| -import time |
24 | 23 |
|
25 | 24 | import adafruit_requests as requests
|
| 25 | +from adafruit_wsgi.wsgi_app import WSGIApp |
26 | 26 | from adafruit_wiznet5k.adafruit_wiznet5k import WIZNET5K
|
27 | 27 | import adafruit_wiznet5k.adafruit_wiznet5k_socket as socket
|
28 | 28 | import adafruit_wiznet5k.adafruit_wiznet5k_wsgiserver as server
|
29 |
| -from adafruit_wsgi.wsgi_app import WSGIApp |
30 | 29 |
|
31 | 30 |
|
32 | 31 | print("Wiznet5k Web Server Test")
|
33 | 32 |
|
34 | 33 |
|
35 |
| -def get_mac(i2c): |
| 34 | +def get_mac(i2c_obj): |
36 | 35 | "Read MAC from 24AA02E48 chip and return it"
|
37 |
| - mac = bytearray(6) |
38 |
| - while not i2c.try_lock(): |
| 36 | + mac_addr = bytearray(6) |
| 37 | + while not i2c_obj.try_lock(): |
39 | 38 | pass
|
40 |
| - i2c.writeto(0x50, bytearray((0xFA,))) |
41 |
| - i2c.readfrom_into(0x50, mac, start=0, end=6) |
42 |
| - i2c.unlock() |
43 |
| - return mac |
| 39 | + i2c_obj.writeto(0x50, bytearray((0xFA,))) |
| 40 | + i2c_obj.readfrom_into(0x50, mac_addr, start=0, end=6) |
| 41 | + i2c_obj.unlock() |
| 42 | + return mac_addr |
44 | 43 |
|
45 | 44 |
|
46 | 45 | def get_static_file(filename):
|
47 | 46 | "Static file generator"
|
48 | 47 | with open(filename, "rb") as f:
|
49 |
| - bytes = None |
50 |
| - while bytes is None or len(bytes) == 2048: |
51 |
| - bytes = f.read(2048) |
52 |
| - yield bytes |
| 48 | + b = None |
| 49 | + while b is None or len(b) == 2048: |
| 50 | + b = f.read(2048) |
| 51 | + yield b |
53 | 52 |
|
54 | 53 |
|
55 | 54 | # Status LED
|
@@ -107,13 +106,13 @@ def large(request): # pylint: disable=unused-argument
|
107 | 106 |
|
108 | 107 |
|
109 | 108 | @web_app.route("/code")
|
110 |
| -def large(request): # pylint: disable=unused-argument |
| 109 | +def code(request): # pylint: disable=unused-argument |
111 | 110 | print("Static file code.py handler")
|
112 | 111 | return ("200 OK", [], get_static_file("code.py"))
|
113 | 112 |
|
114 | 113 |
|
115 | 114 | @web_app.route("/btc")
|
116 |
| -def btc(request): |
| 115 | +def btc(request): # pylint: disable=unused-argument |
117 | 116 | print("BTC handler")
|
118 | 117 | r = requests.get("http://api.coindesk.com/v1/bpi/currentprice/USD.json")
|
119 | 118 | result = r.text
|
|
0 commit comments