2017-05-07 92 views
0

嗨,我正在製作一個機器人控制系統,我想通過我所做的一個網站來控制它。但是,我無法找到一種方法將其鏈接到Python代碼來控制樹莓派GPIO。通過HTML代碼控制python代碼

我的網站的活動版本是www.awesomecoding.co.uk這裏是HTML源代碼:

<html> 
<head> 
    <style type="text/css"> 
     #commands{ 
      text-align: center; 
      color: FF8300; 
      font-size: 100px; 
     } 
     .controllbox{ 
      width: 610px; 
      margin: 0 auto; 
     } 
     #arrowUp{ 
      text-align: center; 
      position: static; 
     } 
     #arrowRight{ 
      text-align: right; 
      position: static; 
      margin-top: 0; 
     } 
     #arrowDown{ 
      text-align: center; 
      position: static; 
     } 
     #arrowLeft{ 
      text-align: left; 
      position: static; 
      margin-top: -200px; 

     } 
     #stop{ 
      width: 120px; 
      height: auto; 
      margin: 0 auto; 
      margin-top: -65%; 
      margin-left: 34%; 
      text-align: center; 
      position: static; 


     } 
    </style> 
</head> 
<body> 

    <h1 id="commands">Controll Me!!</h1> 
    <div class="controllBox"> 
     <div id="arrowUp"><img src="arrowUp.jpg" class="controll" id="button1"></div> 
     <div id="arrowRight"><img src="arrowRight.jpg" class="controll" id="button2"></div> 
     <div id="arrowLeft"><img src="arrowLeft.jpg" class="controll" id="button3"></div> 
     <div id="arrowDown"><img src="arrowDown.jpg" class="controll" id="button4"></div> 
     <div id="stop"><img src="stop.jpg" class="controll" id="button5"></div> 
    </div> 
<script type="text/javascript"> 

     document.getElementById('button1').onclick = function(){ 
      document.getElementById('commands').innerHTML = 'Foward' 
     } 
     document.getElementById('button2').onclick = function(){ 
      document.getElementById('commands').innerHTML = 'Right' 
     } 
     document.getElementById('button3').onclick = function(){ 
      document.getElementById('commands').innerHTML = 'Left' 
     } 
     document.getElementById('button4').onclick = function(){ 
      document.getElementById('commands').innerHTML = 'Backwards' 
     } 
     document.getElementById('button5').onclick = function(){ 
      document.getElementById('commands').innerHTML = 'Stop' 
     } 

    </script> 
</body> 

我想看看是否有人的認識簡單而不落後的方式來做到這一點。 我感謝你和建議,你可以加入這個項目,我正在做。

回答

0

最好的,簡單的方法是在後端 Flask Doc使用Python燒瓶框架, Flask Tutorial

+0

感謝的是,這證實了我的懷疑,這有很大的幫助,我會考慮它。 –