-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Page web et récupération des données - Flask
Pour l'utiliser, créez un venv et régarder la structure d'un projet flask.
- Loading branch information
1 parent
b9196c4
commit d805283
Showing
5 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from flask import Flask, render_template, request | ||
|
||
def create_app(): | ||
app = Flask(__name__) | ||
|
||
@app.route('/') | ||
def homepage(): | ||
return render_template('formulaire.html') | ||
|
||
@app.route('/post_submit',methods=['get','post']) | ||
def post_submit(): | ||
res = None | ||
if request.method == 'POST': | ||
city = request.form["city"] | ||
meteo = request.form['meteo'] | ||
nrg1 = request.form["energie"] | ||
print("City : ", city, "\nmeteo : ", meteo , "\nenergie : ", nrg1) | ||
res = "Success" | ||
else: | ||
res = 'Error' | ||
|
||
return res | ||
|
||
|
||
return app | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
@import url('https://fonts.googleapis.com/css?family=Lato&display=swap'); | ||
|
||
body { | ||
background-color: #c7c7c7; | ||
font-family: Lato; | ||
padding-top: 50px; | ||
padding-bottom: 50px; | ||
text-align: center; | ||
width: 70%; | ||
} | ||
|
||
h1 { | ||
width: 70%; | ||
margin: auto; | ||
background-color: #fff; | ||
text-align: center; | ||
padding-top: 50px; | ||
padding-bottom: 50px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/style.css') }}"> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> | ||
|
||
|
||
<title>Formulaire</title> | ||
</head> | ||
<body> | ||
<h1>Bienvenue sur SOIVD !</h1> | ||
|
||
<form action="{{url_for('post_submit')}}" method="POST"> | ||
<div class="form-group" > | ||
<label for="city">City</label> | ||
<input type="text" class="form-control" name="city" id="city" placeholder="Toulouse, Paris, Rennes ..."> | ||
</div> | ||
<br> | ||
<div class="form-group"> | ||
<label for="meteo">Infos Météo</label> | ||
<select class="form-control" id="meteo" name="meteo"> | ||
<option>Current Weather</option> | ||
<option>Evening Weather </option> | ||
<option>tomorrow's Weather </option> | ||
<option>Humidity</option> | ||
<option>Etc ... </option> | ||
|
||
</select> | ||
</div> | ||
<br> | ||
<div class="form-group"> | ||
<label for="energie">Infos Energies</label> | ||
<select class="form-control" id="energie" name="energie"> | ||
<option>Requête 1</option> | ||
<option>Requête 2 </option> | ||
<option>Requête 3 </option> | ||
<option>Etc ... </option> | ||
|
||
</select> | ||
</div> | ||
<br> <br> | ||
<button type="submit" class="btn btn-primary">Submit</button> | ||
</form> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Post_Submit</title> | ||
</head> | ||
<body> | ||
<h1>Page de réponse !</h1> | ||
</body> | ||
</html> |