Umstellung auf JSON Antwort
This commit is contained in:
parent
57c152bd7f
commit
16dfddfc79
28
api.py
28
api.py
@ -428,10 +428,10 @@ def page_overview_absence(username: str, year: int):
|
|||||||
else:
|
else:
|
||||||
login = login_mask(target=f'/api/absence/{username}/{year}')
|
login = login_mask(target=f'/api/absence/{username}/{year}')
|
||||||
|
|
||||||
@ui.page('/api/stamp/{api_key}')
|
@app.get('/api/stamp/{api_key}')
|
||||||
def page_api_stamp(api_key: str):
|
def json_stamp(api_key: str):
|
||||||
userlist = list_users()
|
userlist = list_users()
|
||||||
user_dict = { }
|
user_dict = {}
|
||||||
# Dictionary mit Usernamen befüllen
|
# Dictionary mit Usernamen befüllen
|
||||||
for i in userlist:
|
for i in userlist:
|
||||||
user_dict[i] = ""
|
user_dict[i] = ""
|
||||||
@ -442,20 +442,23 @@ def page_api_stamp(api_key: str):
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
found_key = False
|
returndata = {}
|
||||||
|
|
||||||
ui.page_title(f'{app_title} {app_version}')
|
|
||||||
|
|
||||||
for user_key, api_value in user_dict.items():
|
for user_key, api_value in user_dict.items():
|
||||||
if api_key == api_value:
|
if api_key == api_value:
|
||||||
current_user = user(user_key)
|
current_user = user(user_key)
|
||||||
current_user.timestamp()
|
current_user.timestamp()
|
||||||
found_key = True
|
|
||||||
ui.label(f'Zeitstempel {datetime.now().strftime("%H:%M")} für {current_user.fullname} eingetragen')
|
|
||||||
break
|
|
||||||
|
|
||||||
if found_key == False:
|
|
||||||
ui.label("Keinen passenden Benutzer gefunden")
|
returndata["username"] = current_user.username
|
||||||
|
if current_user.stamp_status() == status_in:
|
||||||
|
returndata["stampstatus"] = True
|
||||||
|
else:
|
||||||
|
returndata["stampstatus"] = False
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
returndata["username"] = None
|
||||||
|
|
||||||
|
return returndata
|
||||||
|
|
||||||
@app.get("/api/json/{api_key}")
|
@app.get("/api/json/{api_key}")
|
||||||
def json_info(api_key: str):
|
def json_info(api_key: str):
|
||||||
@ -481,7 +484,6 @@ def json_info(api_key: str):
|
|||||||
month = now_dt.month
|
month = now_dt.month
|
||||||
day = now_dt.day
|
day = now_dt.day
|
||||||
|
|
||||||
found_key = True
|
|
||||||
data = { }
|
data = { }
|
||||||
data["user"] = current_user.username
|
data["user"] = current_user.username
|
||||||
if current_user.stamp_status() == status_in:
|
if current_user.stamp_status() == status_in:
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
import base64
|
import base64
|
||||||
import signal
|
import signal
|
||||||
import time
|
import time
|
||||||
import webbrowser
|
|
||||||
import argparse
|
import argparse
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from fastapi import Response
|
from fastapi import Response
|
||||||
|
from playsound3 import playsound
|
||||||
from definitions import app_title, app_version
|
from definitions import app_title, app_version
|
||||||
|
|
||||||
from nicegui import Client, app, core, run, ui
|
from nicegui import Client, app, core, run, ui
|
||||||
@ -74,9 +74,17 @@ def visual_interface(port=9000):
|
|||||||
|
|
||||||
def function_call():
|
def function_call():
|
||||||
r = requests.get(str(a))
|
r = requests.get(str(a))
|
||||||
|
print(r.content())
|
||||||
|
print("Inside Function_call")
|
||||||
#b = webbrowser.open(str(a))
|
#b = webbrowser.open(str(a))
|
||||||
if r.status_code == 200:
|
if r.status_code == 200:
|
||||||
print(f'Request geglückt: {a}')
|
print('Erkannt')
|
||||||
|
if r.json()["stampstatus"]:
|
||||||
|
playsound('ui-on.mp3')
|
||||||
|
elif not r.json()["stampstatus"]:
|
||||||
|
playsound('ui-off.mp3')
|
||||||
|
else:
|
||||||
|
playsound('ui-sound.mp3')
|
||||||
nonlocal blocker
|
nonlocal blocker
|
||||||
nonlocal blockset
|
nonlocal blockset
|
||||||
blocker = True
|
blocker = True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user