Add new file

This commit is contained in:
starcalc 2018-09-06 21:44:46 +02:00
commit 26ffda7a5d
1 changed files with 22 additions and 0 deletions

22
run.py Normal file
View File

@ -0,0 +1,22 @@
#!/usr/bin/python3
import RPi.GPIO as GPIO
import time
from datetime import datetime
import socket
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT)
GPIO.output(17,GPIO.HIGH)
serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
serversocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
serversocket.bind(('192.168.1.1', 8000))
serversocket.listen(5) # become a server socket, maximum 5 connections
print (round(datetime.utcnow().timestamp() * 1000))
# while True:
connection, address = serversocket.accept()
buf = connection.recv(64)
if len(buf) > 0:
print (buf)
print (round(datetime.utcnow().timestamp() * 1000))
serversocket.close()
GPIO.output(17,GPIO.LOW)