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:
|
||||
login = login_mask(target=f'/api/absence/{username}/{year}')
|
||||
|
||||
@ui.page('/api/stamp/{api_key}')
|
||||
def page_api_stamp(api_key: str):
|
||||
@app.get('/api/stamp/{api_key}')
|
||||
def json_stamp(api_key: str):
|
||||
userlist = list_users()
|
||||
user_dict = { }
|
||||
user_dict = {}
|
||||
# Dictionary mit Usernamen befüllen
|
||||
for i in userlist:
|
||||
user_dict[i] = ""
|
||||
@ -442,20 +442,23 @@ def page_api_stamp(api_key: str):
|
||||
except:
|
||||
pass
|
||||
|
||||
found_key = False
|
||||
|
||||
ui.page_title(f'{app_title} {app_version}')
|
||||
|
||||
returndata = {}
|
||||
for user_key, api_value in user_dict.items():
|
||||
if api_key == api_value:
|
||||
current_user = user(user_key)
|
||||
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}")
|
||||
def json_info(api_key: str):
|
||||
@ -481,7 +484,6 @@ def json_info(api_key: str):
|
||||
month = now_dt.month
|
||||
day = now_dt.day
|
||||
|
||||
found_key = True
|
||||
data = { }
|
||||
data["user"] = current_user.username
|
||||
if current_user.stamp_status() == status_in:
|
||||
|
@ -2,13 +2,13 @@
|
||||
import base64
|
||||
import signal
|
||||
import time
|
||||
import webbrowser
|
||||
import argparse
|
||||
import requests
|
||||
|
||||
import cv2
|
||||
import numpy as np
|
||||
from fastapi import Response
|
||||
from playsound3 import playsound
|
||||
from definitions import app_title, app_version
|
||||
|
||||
from nicegui import Client, app, core, run, ui
|
||||
@ -74,9 +74,17 @@ def visual_interface(port=9000):
|
||||
|
||||
def function_call():
|
||||
r = requests.get(str(a))
|
||||
print(r.content())
|
||||
print("Inside Function_call")
|
||||
#b = webbrowser.open(str(a))
|
||||
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 blockset
|
||||
blocker = True
|
||||
|
Loading…
x
Reference in New Issue
Block a user