@@ -39,9 +39,7 @@ def status_handler(mode, status, ip):
39
39
from tinyweb .server import webserver
40
40
41
41
except ImportError :
42
- # WIFI settings
43
- WIFI_COUNTRY = "GB" # Change to your local two-letter ISO 3166-1 country code
44
- network_manager = NetworkManager (WIFI_COUNTRY , status_handler = status_handler )
42
+ network_manager = NetworkManager (WIFI_CONFIG .COUNTRY , status_handler = status_handler )
45
43
uasyncio .get_event_loop ().run_until_complete (network_manager .client (WIFI_CONFIG .SSID , WIFI_CONFIG .PSK ))
46
44
# Install missing module
47
45
import upip
@@ -53,16 +51,6 @@ def status_handler(mode, status, ip):
53
51
app = webserver ()
54
52
55
53
56
- # Static page
57
- if is_mini :
58
- html_file = open ('index_mini.html' , 'r' )
59
- else :
60
- html_file = open ('index.html' , 'r' )
61
-
62
- # WIFI settings
63
- WIFI_COUNTRY = "GB" # Change to your local two-letter ISO 3166-1 country code
64
-
65
-
66
54
class LEDs :
67
55
68
56
def not_exists (self ):
@@ -196,10 +184,10 @@ def post(self, data):
196
184
# Index page
197
185
@app .route ('/' )
198
186
async def index (request , response ):
199
- # Start HTTP response with content-type text/html
200
- await response .start_html ( )
201
- # Send actual HTML page
202
- await response .send ( html_file . read () )
187
+ if is_mini :
188
+ await response .send_file ( 'index_mini.html' , content_type = 'text/html' )
189
+ else :
190
+ await response .send_file ( 'index.html' , content_type = 'text/html' )
203
191
204
192
205
193
# HTTP redirection
@@ -211,7 +199,7 @@ async def redirect(request, response):
211
199
212
200
def run ():
213
201
# Setup wifi
214
- network_manager = NetworkManager (WIFI_COUNTRY , status_handler = status_handler )
202
+ network_manager = NetworkManager (WIFI_CONFIG . COUNTRY , status_handler = status_handler )
215
203
216
204
app .add_resource (outputs , '/outputs' )
217
205
app .add_resource (relays , '/relays' )
0 commit comments