FLASK:function either returned None ended without a return statement.

di il
1 risposte

FLASK:function either returned None ended without a return statement.

Salve a tutti , sto creando un applicazione per un rover robotico In Python su Flask , ho creato dei pulsanti e impostato il form creato il software di supporto con l' applicazione python , ma mi da questo errore , purtoppo non sono tanto esperto da poter fare un debug adeguato comunque , ecco i listati di python e html

                
@app.route('/' , methods=['GET','POST'])
def index():
  TASTO="STANDBY"
  submit_button="0"
  if request.method == ['POST']:
       if request.form['submit_button'] == "":
           TASTO="STANDBY"
       elif request.form['submit_button'] == "1":
           TASTO="FORWARD"
       elif request.form['submit_button'] == "2":
           TASTO="BACKWARD"
       elif request.form['submit_button'] == "3":
           TASTO="RIGTH"
       elif request.form['submit_button'] == "4":
           TASTO="LEFT"
       elif request.form['submit_button'] == "5":
           TASTO="STOP-RUN"
       elif request.form['submit_button'] == "6":
           TASTO="UP-CAMERA"
       elif request.form['submit_button'] == "7":
           TASTO="DOWN-CAMERA"
       elif request.form['submit_button'] == "8":
           TASTO="RIGTH-CAMERA"
       elif request.form['submit_button'] == "9":
           TASTO="LEFT-CAMERA"   
       elif request.form['submit_button'] == "10":
           TASTO="STOP-CAMERA"        
       elif request.form['submit_button'] == "11":
           TASTO="START-DATA"
       elif request.form['submit_button'] == "12":
           TASTO="STOP-DATA"
       elif request.form['submit_button'] == "13":
           TASTO="LIGTH-ON"        
       else:
           request.form['submit_button'] == "14"
           TASTO="LIGTH-OFF"
           return render_template("/home/antonio/PYTHON_TO_HTML/templates/index.html" , form=form  ,  button_message=TASTO  ) 
<!DOCTYPE html>
{% extends "PYTHON_TO_HTML.html" %}
{% block body %}
<style>
  .menu {
     float:left;
     width:20%;
     height:80%;
   }
   .mainContent {
     float:rigth;
     width:75%;
     height:80%;
   }
 </style>
 <img src="{{('video_feed')}}" width="640" height="480" style='float:left;margin: 10px'/>
 <form method="POST" action="/" enctype="multipart/form-data">
 <input type="submit"  name="submit_button" value="1" style='float:center;margin: 10px'>FORWARD</button>
 <button type="submit"  name="submit_button" value="2" style='float:center;margin: 10px'>BACKWARD</button>
 <button type="submit"  name="submit_button" value="3" style='float:center;margin: 10px'>RIGTH</button>
 <button type="submit"  name="submit_button" value="4" style='float:center;margin: 10px'>LEFT</button>
 <button type="submit"  name="submit_button" value="5" style='float:center;margin: 10px'>STOP-RUN</button>
 <button type="submit"  name="submit_button" value="6" style='float:center;margin: 10px'>UP-CAMERA</button>
 <button type="submit"  name="submit_button" value="7" style='float:center;margin: 10px'>DOWN-CAMERA</button>
 <button type="submit"  name="submit_button" value="8" style='float:center;margin: 10px'>RIGTH-CAMERA</button>
 <button type="submit"  name="submit_button" value="9" style='float:center;margin: 10px'>LEFT-CAMERA</button>
 <button type="submit"  name="submit_button" value="10" style='float:center;margin: 10px'>STOP-CAMERA</button>
 <button type="submit"  name="submit_button" value="11" style='float:center;margin: 10px'>START-DATA</button>
 <button type="submit"  name="submit_button" value="12" style='float:center;margin: 10px'>STOP-DATA</button>
 <button type="submit"  name="submit_button" value="13" style='float:center;margin: 10px'>LIGTH-ON</button>  
 <button type="submit"  name="submit_button" value="14" style='float:center;margin: 10px'>LIGTH-OFF</button>
 </form>
 
<p> {{button_message}}<p>
<body>
 
 <iframe class="mainContent" src="{{('tabelle')}}"></iframe>
</body>
{% endblock %}

Ringrazio chiunque interverra' 

1 Risposte

Devi accedere o registrarti per scrivere nel forum
1 risposte