Skip to content

Commit

Permalink
Page web et récupération des données - Flask
Browse files Browse the repository at this point in the history
Pour l'utiliser, créez un venv et régarder la structure d'un projet flask.
  • Loading branch information
Abakar-Issa authored Nov 24, 2022
1 parent b9196c4 commit d805283
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 0 deletions.
26 changes: 26 additions & 0 deletions app_flask/__init__.py
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 added app_flask/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
19 changes: 19 additions & 0 deletions app_flask/static/css/style.css
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;
}
48 changes: 48 additions & 0 deletions app_flask/templates/formulaire.html
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>
12 changes: 12 additions & 0 deletions app_flask/templates/post_login.html
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>

0 comments on commit d805283

Please sign in to comment.