commit
1419a436ab
6 changed files with 66 additions and 0 deletions
@ -0,0 +1 @@ |
|||
venv |
@ -0,0 +1,23 @@ |
|||
# Applicazione base per Flask # |
|||
|
|||
Applicazione minimale per il calcolo dell'area del rettangolo sulla base di |
|||
due dati. |
|||
|
|||
# Installazione # |
|||
|
|||
Installare Python e le eventuali dipendenze: |
|||
|
|||
apt-get install python python-pip python-dev |
|||
|
|||
Quindi installare le dipendenze dell'applicazione |
|||
|
|||
pip install -r requirements.txt |
|||
|
|||
# Esecuzione dell'applicazione # |
|||
|
|||
È sufficiente eseguire il file python: |
|||
|
|||
python app.py |
|||
|
|||
Quindi si può aprire il browser all'indirizzo |
|||
[http://localhost:5000](http://localhost:5000) per guardare l'applicazione. |
@ -0,0 +1,14 @@ |
|||
from flask import Flask, request, render_template |
|||
app = Flask(__name__) |
|||
|
|||
@app.route('/') |
|||
def baseform(): |
|||
return render_template('modulo.html') |
|||
|
|||
@app.route('/area_rettangolo', methods=['POST']) |
|||
def saluta(): |
|||
area = int(request.form['base']) * int(request.form['altezza']) |
|||
return render_template('area.html', area_calcolata=area) |
|||
|
|||
if __name__ == '__main__': |
|||
app.run() |
@ -0,0 +1,6 @@ |
|||
Click==7.0 |
|||
Flask==1.1.1 |
|||
itsdangerous==1.1.0 |
|||
Jinja2==2.10.3 |
|||
MarkupSafe==1.1.1 |
|||
Werkzeug==0.16.0 |
@ -0,0 +1,8 @@ |
|||
<!doctype html> |
|||
<html> |
|||
<body> |
|||
<title>Calcola l'area del rettangolo</title> |
|||
|
|||
<p>L'area del triangolo è {{ area_calcolata }}</p> |
|||
</body> |
|||
</html> |
@ -0,0 +1,14 @@ |
|||
<!doctype html> |
|||
<html> |
|||
<body> |
|||
<title>Calcola l'area del rettangolo</title> |
|||
|
|||
<p><form action="/area_rettangolo" method="post"> |
|||
<label for="base">Lunghezza della base:</label> |
|||
<input type="text" name="base" /><br/> |
|||
<label for="altezza">Lunghezza dell'altezza:</label> |
|||
<input type="text" name="altezza" /><br/> |
|||
<input type="submit" name="Calcola" /> |
|||
</form></p> |
|||
</body> |
|||
</html> |
Loading…
Reference in new issue