mirror of
https://github.com/iFargle/headscale-webui.git
synced 2026-01-06 04:33:58 +01:00
test
This commit is contained in:
10
renderer.py
10
renderer.py
@@ -231,7 +231,7 @@ def thread_machine_content(machine, machine_content, idx):
|
||||
<p><div>
|
||||
"""
|
||||
for route in pulled_routes["routes"]:
|
||||
# log.info("Route: ["+str(route['machine']['name'])+"] id: "+str(route['id'])+" / prefix: "+str(route['prefix'])+" enabled?: "+str(route['enabled']))
|
||||
# app.logger.warning("Route: ["+str(route['machine']['name'])+"] id: "+str(route['id'])+" / prefix: "+str(route['prefix'])+" enabled?: "+str(route['enabled']))
|
||||
# Check if the route is enabled:
|
||||
route_enabled = "red"
|
||||
route_tooltip = 'enable'
|
||||
@@ -369,7 +369,7 @@ def thread_machine_content(machine, machine_content, idx):
|
||||
preauth_key = str(preauth_key),
|
||||
machine_tags = Markup(tags),
|
||||
)))
|
||||
log.info("Finished thread for machine "+machine["givenName"]+" index "+str(idx))
|
||||
app.logger.warning("Finished thread for machine "+machine["givenName"]+" index "+str(idx))
|
||||
|
||||
# Render the cards for the machines page:
|
||||
def render_machines_cards():
|
||||
@@ -383,14 +383,14 @@ def render_machines_cards():
|
||||
iterable = []
|
||||
machine_content = {}
|
||||
for i in range (0, numThreads):
|
||||
log.info("Appending iterable: "+str(i))
|
||||
app.logger.debug("Appending iterable: "+str(i))
|
||||
iterable.append(i)
|
||||
# Flask-Executor Method:
|
||||
log.info("Starting futures")
|
||||
app.logger.warning("Starting futures")
|
||||
futures = [executor.submit(thread_machine_content, machines_list["machines"][idx], machine_content, idx) for idx in iterable]
|
||||
# Wait for the executor to finish all jobs:
|
||||
wait(futures, return_when=ALL_COMPLETED)
|
||||
log.info("Finished futures")
|
||||
app.logger.warning("Finished futures")
|
||||
|
||||
# DEBUG: Do in a forloop:
|
||||
# for idx in iterable: thread_machine_content(machines_list["machines"][idx], machine_content, idx)
|
||||
|
||||
27
server.py
27
server.py
@@ -2,7 +2,6 @@ import requests, json, renderer, headscale, helper, sys, pytz, os, time
|
||||
from flask import Flask, render_template, request, url_for, redirect, Markup
|
||||
from datetime import datetime, timedelta, date
|
||||
from dateutil import parser
|
||||
from logging.config import dictConfig
|
||||
|
||||
# Threading to speed things up
|
||||
from concurrent.futures import wait, ALL_COMPLETED
|
||||
@@ -20,32 +19,14 @@ GIT_BRANCH = os.environ["GIT_BRANCH"]
|
||||
HS_VERSION = "v0.20.0"
|
||||
DEBUG_STATE = False
|
||||
|
||||
# https://flask.palletsprojects.com/en/2.2.x/logging/#basic-configuration
|
||||
dictConfig({
|
||||
'version': 1,
|
||||
'formatters': {'default': {
|
||||
'format': '[%(asctime)s] %(levelname)s in %(module)s: %(message)s',
|
||||
}},
|
||||
'handlers': {'wsgi': {
|
||||
'class': 'logging.StreamHandler',
|
||||
'stream': 'ext://flask.logging.wsgi_errors_stream',
|
||||
'formatter': 'default'
|
||||
}},
|
||||
'root': {
|
||||
'level': 'INFO',
|
||||
'handlers': ['wsgi']
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
static_url_path = '/static'
|
||||
if BASE_PATH != '': static_url_path = BASE_PATH + static_url_path
|
||||
|
||||
app = Flask(__name__, static_url_path=static_url_path)
|
||||
executor = Executor(app)
|
||||
|
||||
app.logger.info("Static assets served on: "+static_url_path)
|
||||
app.logger.info("BASE_PATH: "+BASE_PATH)
|
||||
app.logger.warning("Static assets served on: "+static_url_path)
|
||||
app.logger.warning("BASE_PATH: "+BASE_PATH)
|
||||
|
||||
########################################################################################
|
||||
# / pages - User-facing pages
|
||||
@@ -148,8 +129,8 @@ def test_key_page():
|
||||
if status != 200: return "Unauthenticated"
|
||||
|
||||
renewed = headscale.renew_api_key(url, api_key)
|
||||
app.logger.info("The below statement will be TRUE if the key has been renewed or DOES NOT need renewal. False in all other cases")
|
||||
app.logger.info("Renewed: "+str(renewed))
|
||||
app.logger.warning("The below statement will be TRUE if the key has been renewed or DOES NOT need renewal. False in all other cases")
|
||||
app.logger.warning("Renewed: "+str(renewed))
|
||||
# The key works, let's renew it if it needs it. If it does, re-read the api_key from the file:
|
||||
if renewed: api_key = headscale.get_api_key()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user