Page 64 - MDP2020-2
P. 64
| 인천전자마이스터고등학교 ·············································································································
58
9. 소프트웨어 작성
-door.py
# -*- coding:utf-8 -*-
from selenium import webdriver
from flask import Flask, request
from flask import render_template
import RPi.GPIO as GPIO
INA = 5 #L298 INA
INB = 3 #L298 INB
sensor = 11 #PIR SENSOR
HIGH = 1
LOW = 0
#-----웹크롤링 프로그램----
import time
from selenium import webdriver
browser = webdriver.Chrome('/usr/lib/chromium-browser/chromedriver')
url = "http://0.0.0.0:8080/panel"
browser.get(url)
time.sleep(1)
width = browser.find_element_by_xpath('//*[@id="width"]')
width.clear()
width.send_keys("640")
height = browser.find_element_by_xpath('//*[@id="height"]')
height.clear()
height.send_keys("480")
jpeg_quality = browser.find_element_by_xpath('//*[@id="134217739"]')
jpeg_quality.clear()
jpeg_quality.send_keys("5")
frame_rate = browser.find_element_by_xpath('//*[@id="134217741"]')
frame_rate.clear()
frame_rate.send_keys("80")
button = browser.find_element_by_xpath('//*[@id="settings"]/input[2]').click()
browser.quit()
#--------------------------
app = Flask(__name__)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(sensor,GPIO.IN)
GPIO.setup(INA, GPIO.OUT)
GPIO.setup(INB, GPIO.OUT)
GPIO.output(INA, LOW)
GPIO.output(INB, HIGH)
@app.route("/") #메인 설정 화면
def apt():
return render_template("index1.html") #index1 호출
@app.route("/house") #집 내부 화면
def home():