Logging Kapitel
This commit is contained in:
@@ -18,6 +18,7 @@ CC-BY-SA Olli Graf
|
||||
|11 | Datum und Zeit|
|
||||
|12 | Multithreading|
|
||||
|13 | Netzwerk|
|
||||
|14 | GPIO|
|
||||
|15 | Testing|
|
||||
|14 | Logging|
|
||||
|15 | GPIO|
|
||||
|16 | Testing|
|
||||
|
||||
|
2
gpio/.gitignore
vendored
Normal file
2
gpio/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
./__pycache__
|
||||
./network/__pycache__/*
|
BIN
gpio/__pycache__/led.cpython-39.pyc
Normal file
BIN
gpio/__pycache__/led.cpython-39.pyc
Normal file
Binary file not shown.
1
gpio/ledserver.log
Normal file
1
gpio/ledserver.log
Normal file
@@ -0,0 +1 @@
|
||||
2023-04-29 10:49:08,638 [DEBUG] <module>: MAIN: start
|
32
gpio/ledserver.py
Executable file
32
gpio/ledserver.py
Executable file
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/python3
|
||||
from http.server import BaseHTTPRequestHandler,HTTPServer
|
||||
import logging
|
||||
|
||||
logging.basicConfig( format='%(asctime)-15s [%(levelname)s] %(funcName)s: %(message)s', filename='ledserver.log', level=logging.DEBUG)
|
||||
class http_server:
|
||||
def __init__(self):
|
||||
def handler(*args):
|
||||
myHandler(*args)
|
||||
server = HTTPServer(('', 8080), handler)
|
||||
|
||||
class myHandler(BaseHTTPRequestHandler):
|
||||
def __init__(self,*args):
|
||||
self.t1 = t1
|
||||
BaseHTTPRequestHandler.__init__(self, *args)
|
||||
|
||||
def do_GET(self):
|
||||
logging.debug('GET: empfangen')
|
||||
self.send_response(200)
|
||||
self.send_header('Content-type','text/html')
|
||||
self.end_headers()
|
||||
self.wfile.write(self.t1.show()) #Doesnt work
|
||||
return
|
||||
|
||||
class main:
|
||||
def __init__(self):
|
||||
|
||||
self.server = http_server()
|
||||
|
||||
if __name__ == '__main__':
|
||||
logging.debug('MAIN: start')
|
||||
main()
|
3
gpio/network/__init__.py
Normal file
3
gpio/network/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from .const import __ADDRESSLOCAL__
|
||||
#from .const import __ADDRESSREMOTE__
|
||||
|
BIN
gpio/network/__pycache__/__init__.cpython-39.pyc
Normal file
BIN
gpio/network/__pycache__/__init__.cpython-39.pyc
Normal file
Binary file not shown.
BIN
gpio/network/__pycache__/const.cpython-39.pyc
Normal file
BIN
gpio/network/__pycache__/const.cpython-39.pyc
Normal file
Binary file not shown.
10
gpio/network/code.py
Normal file
10
gpio/network/code.py
Normal file
@@ -0,0 +1,10 @@
|
||||
def receive(conn):
|
||||
msg = conn.recv(64).decode('utf-8')
|
||||
|
||||
return msg
|
||||
|
||||
def send(client, msg):
|
||||
message = msg.encode('utf-8')
|
||||
client.send(message)
|
||||
|
||||
|
19
gpio/network/const.py
Normal file
19
gpio/network/const.py
Normal file
@@ -0,0 +1,19 @@
|
||||
#network/const.py
|
||||
|
||||
import socket
|
||||
|
||||
# TCP Port
|
||||
__PORT__ = 6554
|
||||
|
||||
#Server-IP
|
||||
# für den Server (immer localhost)
|
||||
__SERVERLOCAL__ = socket.gethostbyname(socket.gethostname())
|
||||
|
||||
#für Server auf einem Remote-Pi
|
||||
#__SERVERREMOTE__ = socket.gethostbyname('gabbo')
|
||||
|
||||
# Server-Adresse (IP,Port)
|
||||
#lokal
|
||||
__ADDRESSLOCAL__ = (__SERVERLOCAL__,__PORT__)
|
||||
#remote
|
||||
#__ADDRESSREMOTE__ = (__SERVERREMOTE__,__PORT__)
|
Reference in New Issue
Block a user