Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Spot-Welder-Control/System.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
37 lines (29 sloc)
1.19 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''Import all system libraries''' | |
import time, socket, datetime, os, fcntl, struct, sqlite3 #import time, IP, time and date | |
from flask import Flask, render_template, request, jsonify, request, send_file, redirect, url_for #import web app | |
import netifaces as ni | |
import RPi.GPIO as GPIO | |
import SystemLibrary as L | |
GPIO.setmode(GPIO.BCM) # choose BCM or BOARD | |
GPIO.setup(14, GPIO.OUT) | |
os.system('clear') | |
IP = L.get_IP() | |
L.displayTime() | |
#L.shift(str(L.getCurrentBinary), 2) | |
app = Flask(__name__) | |
global int_time | |
int_time = datetime.datetime.now() | |
@app.route('/') #Sets index | |
def index(): | |
return render_template('index.html') #Displays HTML page 'Relay.html'# | |
@app.route('/relay/<username>', methods=['GET', 'POST']) | |
def checkSwitch(username): | |
timing = float(username) | |
GPIO.output(14, 0) # set GPIO24 to 1/GPIO.HIGH/True | |
time.sleep(timing) # wait half a second | |
GPIO.output(14, 1) # set GPIO24 to 0/GPIO.LOW/False | |
time.sleep(timing) # wait half a second | |
return render_template('index.html') | |
if __name__ == '__main__': | |
app.run(debug=True, host=(str(IP)), threaded=True, port=80) | |
GPIO.cleanup() |