Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Flavian Amiel committed Apr 25, 2017
2 parents be2ed9c + d2b2550 commit c8890dc
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 11 deletions.
Empty file.
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
# ProjetIot
# Qweekly

Service NFC pour gagner du temps.

## Service node

Passerelle entre la Raspberry Pi et l'affichage Web.

## Service python

Permet a l'utilisateur de passer une carte et RFID pour, selon les cas :
- Afficher son calendrier
- Payer la cantine

## Vue HTML

Interface utilisateur pour gerer son compte :
- Crediter son compte grace a Stripe
- Verifier ses credits

## Base de donnees

Permet de stocker les utilisateurs avec leur tag RFID et leur credit.

## Credits

Coder avec :heart: par Les 4 Fantastiques
4 changes: 3 additions & 1 deletion html/loginCompte.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
url: "http://docker-pi.local:5000/login",
data: jQuery.parseJSON(`{ "name" : "${username}", "password" : "${encryptedPass}" }`),
success : function(){

console.log("User found");
OuvrirPageCredit(username);

Expand All @@ -54,6 +53,9 @@

console.log("An error occured : " + data.statusCode)

// for( e in data){
// console.log(e)
// }
}


Expand Down
17 changes: 8 additions & 9 deletions python/Stripe/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import RPi.GPIO as GPIO
import time

app = Flask(__name__, static_url_path='/home/pi/ProjetIot/node/cantine/')
app = Flask(__name__)
CORS(app)

db = MySQLdb.connect(host="172.30.0.123",
Expand All @@ -31,33 +31,32 @@ def payment():
for c in cur.fetchall():
print c[0]

#test nombre de credit
if (c[0] - 5 < 0) :
#Si pas assez de sous LED Rouge
GPIO.output(16, GPIO.HIGH)
time.sleep(1)
GPIO.output(16, GPIO.LOW)

resp = make_response("Votre compte semble ne plus avoir assez de credit. Merci de le crediter.",403)
return resp
# return render_template('index.html',
# title='Paiement cantine',
# message="Votre compte semble ne plus avoir assez de credit. Merci de le crediter.")


credit = c[0] - 5

#on mets a jour le credit de l'user en lui enlevant les 5euros de la cantine
cur.execute("UPDATE user SET credit="+str(credit)+" WHERE rfid=\'"+request.form['rfid']+"\'")
cur.execute("SELECT credit FROM user where rfid=\'"+request.form['rfid']+"\'")
for c in cur.fetchall():
print c[0]

resp = make_response(json.dumps({"credit" : c[0]}, 201))
# return render_template('success.html',
# title='Paiement cantine',
# credit=c[0]
# )

#led verte
GPIO.output(26, GPIO.HIGH)
time.sleep(1)
GPIO.output(26, GPIO.LOW)
except:
#si erreur led Rouge
resp = make_response("Error", 500)
GPIO.output(16, GPIO.HIGH)
time.sleep(1)
Expand Down

0 comments on commit c8890dc

Please sign in to comment.