Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from flask import Flask, render_template, Response
- from camera import Camera
- import serial
- from flask import Flask, render_template, Response
- from camera import Camera
- import serial
- import subprocess
- arduino = serial.Serial('/dev/ttyACM0', 9600)
- app = Flask(__name__)
- @app.route('/')
- def index():
- return render_template('index.html')
- def gen(camera):
- while True:
- frame = camera.get_frame()
- yield (b'--frame\r\n'
- b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')
- @app.route('/video_feed')
- def video_feed():
- return Response(gen(Camera()),
- mimetype='multipart/x-mixed-replace; boundary=frame')
- @app.route("/feed")
- def feed():
- try:
- arduino.write('a')
- return "1"
- except:
- pass
- return "0"
- def sendAutostartMail():
- import smtplib
- import string
- USER='wnsrud6839@gamil.com'
- PASS='pjkrud6839'
- TO='wnsrud0111@naver.com'
- SUBJECT='Feed!!!!'
- ip = subprocess.check_output("hostname -I", shell= True)
- TEXT = 'your RPs IP addess is %s.\n Please connect here and click Feed' %ip
- FROM = USER
- HOST = 'smtp.gmail.com:587'
- BODY = string.join((
- 'From: %s' %FROM,
- 'To: %s' %TO,
- 'Subject: %s' %SUBJECT,
- '\r\n',
- TEXT,
- ), '\r\n')
- server=smtplib.SMTP(HOST)
- server.starttls()
- server.login(USER, PASS)
- server.sendmail(FROM, TO, BODY)
- server.quit()
- return null;
- if __name__ == '__main__':
- app.run(host='0.0.0.0', debug=True, threaded=True)
- sendAutostartMail()
- import subprocess
- arduino = serial.Serial('/dev/ttyACM0', 9600)
- app = Flask(__name__)
- @app.route('/')
- def index():
- return render_template('index.html')
- def gen(camera):
- while True:
- frame = camera.get_frame()
- yield (b'--frame\r\n'
- b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')
- @app.route('/video_feed')
- def video_feed():
- return Response(gen(Camera()),
- mimetype='multipart/x-mixed-replace; boundary=frame')
- @app.route("/feed")
- def feed():
- try:
- arduino.write('a')
- return "1"
- except:
- pass
- return "0"
- def sendAutostartMail():
- import smtplib
- import string
- USER='wnsrud6839@gamil.com'
- PASS='pjkrud6839'
- TO='wnsrud0111@naver.com'
- SUBJECT='Feed!!!!'
- ip = subprocess.check_output("hostname -I", shell= True)
- TEXT = 'your RPs IP addess is %s.\n Please connect here and click Feed' %ip
- FROM = USER
- HOST = 'smtp.gmail.com:587'
- BODY = string.join((
- 'From: %s' %FROM,
- 'To: %s' %TO,
- 'Subject: %s' %SUBJECT,
- '\r\n',
- TEXT,
- ), '\r\n')
- server=smtplib.SMTP(HOST)
- server.starttls()
- server.login(USER, PASS)
- server.sendmail(FROM, TO, BODY)
- server.quit()
- return null;
- if __name__ == '__main__':
- app.run(host='0.0.0.0', debug=True, threaded=True)
- sendAutostartMail()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement