Skip to content

Commit

Permalink
restart logic simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
n1kdo committed Feb 7, 2024
1 parent 64a596b commit d034989
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/kpa500-remote/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def value(self):
DEFAULT_WEB_PORT = 80

# globals...
restart = False
keep_running = True
username = ''
password = ''
http_server = HttpServer(content_dir='content/')
Expand Down Expand Up @@ -159,7 +159,7 @@ async def slash_callback(http, verb, args, reader, writer, request_headers=None)
async def api_config_callback(http, verb, args, reader, writer, request_headers=None): # callback for '/api/config'
if verb == 'GET':
payload = read_config()
# payload.pop('secret') # do not return the secret
payload.pop('secret') # do not return the secret
response = json.dumps(payload).encode('utf-8')
http_status = 200
bytes_sent = http.send_simple_response(writer, http_status, http.CT_APP_JSON, response)
Expand Down Expand Up @@ -263,9 +263,9 @@ async def api_config_callback(http, verb, args, reader, writer, request_headers=

# noinspection PyUnusedLocal
async def api_restart_callback(http, verb, args, reader, writer, request_headers=None):
global restart
global keep_running
if upython:
restart = True
keep_running = False
response = b'ok\r\n'
http_status = 200
bytes_sent = http.send_simple_response(writer, http_status, http.CT_TEXT_TEXT, response)
Expand Down Expand Up @@ -494,7 +494,7 @@ async def api_kat_set_bypass_callback(http, verb, args, reader, writer, request_


async def main():
global restart, username, password, kpa500, kat500
global keep_running, username, password, kpa500, kat500

logging.info('Starting...', 'main:main')

Expand Down Expand Up @@ -592,7 +592,6 @@ async def main():
else:
logging.error('no network connection', 'main:main')

keep_running = True
reset_button_pressed_count = 0
while keep_running:
if upython:
Expand Down

0 comments on commit d034989

Please sign in to comment.