modified: templates/profil.html
modified: views/profil.py
This commit is contained in:
parent
87a088f54d
commit
aef308e3fd
@ -20,7 +20,7 @@
|
||||
<div id="fic">
|
||||
<label> Photo de profil </label>
|
||||
<input type="file" name="fic" id="fic"/><br>
|
||||
<img id="fic" src="/static/usersprofil/{{ profil['avatar'] }}" class="img-rounded" alt=""/>
|
||||
<img id="fic" src="/profil/{{ profil['avatar'] }}" class="img-rounded" alt=""/>
|
||||
</div>
|
||||
<br>
|
||||
<label>Nom </label>
|
||||
|
@ -1,4 +1,4 @@
|
||||
from flask import Blueprint, Flask, request, flash, render_template, url_for, session, redirect, abort, make_response, send_file, escape, flash, abort
|
||||
from flask import Blueprint, Flask, request, flash, render_template, url_for, session, redirect, abort, make_response, send_file, escape, flash, abort, send_from_directory
|
||||
from werkzeug.utils import secure_filename
|
||||
from PIL import Image
|
||||
import time
|
||||
@ -30,12 +30,13 @@ BASE_URL = app.config['BASE_URL']
|
||||
##################################################################################################
|
||||
|
||||
|
||||
@profil.route( '/parametres/', methods=['GET','POST'] )
|
||||
def parametres() :
|
||||
@profil.route( '/profil/<img>', methods=['GET'] )
|
||||
def profil_img(img) :
|
||||
if 'username' in session :
|
||||
return render_template('parametres.html', section='profil')
|
||||
UTILISATEUR='%s' % escape(session['username'])
|
||||
return send_from_directory( os.path.join(DOSSIER_PERSO, UTILISATEUR, 'profile'), img )
|
||||
else:
|
||||
return redirect(url_for('loginlogout.login'))
|
||||
return redirect(BASE_URL, code=401)
|
||||
|
||||
|
||||
|
||||
@ -76,13 +77,13 @@ def profile() :
|
||||
f.save(DOSSIER_PERSO + UTILISATEUR + '/profile/' + nom)
|
||||
image = DOSSIER_PERSO + UTILISATEUR + '/profile/' + nom
|
||||
with Image.open(image) as img:
|
||||
img.tumbnails(resize='80x80')
|
||||
img.save(filename = DOSSIER_PERSO + UTILISATEUR + '/profile/' + nom)
|
||||
imagelocation = DOSSIER_PERSO + UTILISATEUR + '/profile/' + nom
|
||||
img.thumbnail((300,200))
|
||||
img.save( DOSSIER_PERSO + UTILISATEUR + '/profile/' + nom)
|
||||
filename = nom
|
||||
conn = sqlite3.connect(DATABASE) # Connexion à la base de donnée
|
||||
cursor = conn.cursor() # Création de l'objet "curseur"
|
||||
cursor.execute("UPDATE users SET avatar=? WHERE name=?",
|
||||
(imagelocation, UTILISATEUR))
|
||||
(filename, UTILISATEUR))
|
||||
conn.commit()
|
||||
cursor = conn.cursor() # Création de l'objet "curseur"
|
||||
conn.close()
|
||||
|
Loading…
Reference in New Issue
Block a user