Ajout support serveur MAIL et XMPP
This commit is contained in:
118
pywallter.py
118
pywallter.py
@@ -14,8 +14,9 @@ from views.inscription import inscription
|
||||
from views.profil import profil
|
||||
from views.logs import logs
|
||||
from views.loginlogout import loginlogout
|
||||
from views.gallery import mygallery
|
||||
|
||||
from tools.databaseinit import init_db, init_dir
|
||||
from tools.databaseinit import init_db, init_dir, db_migrate
|
||||
|
||||
import glob, os, sys, time
|
||||
|
||||
@@ -23,13 +24,10 @@ app = Flask( 'pywallter' )
|
||||
app.config.from_pyfile('config.py')
|
||||
bcrypt = Bcrypt(app)
|
||||
|
||||
if init_db():
|
||||
print ("La base de données a été créer")
|
||||
exit()
|
||||
|
||||
init_db()
|
||||
db_migrate()
|
||||
if init_dir():
|
||||
print ("Le repertoire des utilisateurs a été créer")
|
||||
exit()
|
||||
|
||||
|
||||
|
||||
@@ -52,85 +50,39 @@ app.register_blueprint(filesupload)
|
||||
app.register_blueprint(profil)
|
||||
app.register_blueprint(logs)
|
||||
app.register_blueprint(loginlogout)
|
||||
|
||||
@app.route( '/gallery/')
|
||||
def gallery():
|
||||
if 'username' in session :
|
||||
UTILISATEUR='%s' % escape(session['username'])
|
||||
THUMBNAILS=DOSSIER_PERSO + UTILISATEUR + '/images/thumbnails/'
|
||||
fichiers = [fich for fich in os.listdir(THUMBNAILS)]
|
||||
return render_template('gallery.html',
|
||||
section='Gallery',
|
||||
THUMBNAILS=THUMBNAILS,
|
||||
fichiers=fichiers)
|
||||
else :
|
||||
return redirect(url_for('loginlogout.login'))
|
||||
|
||||
@app.route( '/parametres/', methods=['GET','POST'] )
|
||||
def parametres() :
|
||||
if 'username' in session :
|
||||
return render_template('parametres.html', section='profil')
|
||||
else:
|
||||
return redirect(url_for('loginlogout.login'))
|
||||
|
||||
@app.route('/remove/<nom>')
|
||||
def remove(nom):
|
||||
if 'username' in session :
|
||||
UTILISATEUR='%s' % escape(session['username'])
|
||||
nom = secure_filename(nom)
|
||||
if os.path.isfile(DOSSIER_PERSO + UTILISATEUR + '/files/' + nom): # si le fichier existe
|
||||
os.remove(DOSSIER_PERSO + UTILISATEUR + '/files/' + nom) # on le supprime
|
||||
return redirect(url_for('filesupload.list', _external=True))
|
||||
else:
|
||||
if os.path.isfile(DOSSIER_PERSO + UTILISATEUR + '/images/thumbnails/' + nom): # si le fichier existe
|
||||
os.remove(DOSSIER_PERSO + UTILISATEUR + '/images/thumbnails/' + nom) # on le supprime
|
||||
os.remove(DOSSIER_PERSO + UTILISATEUR + '/images/' + nom) # on le supprime
|
||||
return redirect(url_for('gallery'))
|
||||
else:
|
||||
flash(u'Fichier {nom} inexistant.'.format(nom=nom), 'error')
|
||||
return redirect(url_for('filesupload.list', _external=True)) # sinon on redirige vers la liste, avec un message d'erreur
|
||||
|
||||
else :
|
||||
return redirect(url_for('loginlogout.login'))
|
||||
|
||||
|
||||
@app.route('/myfiles/<filename>')
|
||||
def myfiles(filename):
|
||||
if 'username' in session :
|
||||
UTILISATEUR='%s' % escape(session['username'])
|
||||
return send_from_directory(
|
||||
os.path.join(DOSSIER_PERSO, UTILISATEUR, 'files'), filename )
|
||||
else :
|
||||
return redirect(url_for('loginlogout.login'))
|
||||
|
||||
|
||||
@app.route('/myfiles/images/<filename>')
|
||||
def myimg(filename):
|
||||
if 'username' in session :
|
||||
UTILISATEUR='%s' % escape(session['username'])
|
||||
return send_from_directory(
|
||||
os.path.join(DOSSIER_PERSO, UTILISATEUR, 'images'), filename )
|
||||
else :
|
||||
return redirect(url_for('loginlogout.login'))
|
||||
|
||||
@app.route('/myfiles/images/thumbnails/<filename>')
|
||||
def mythumbnails(filename):
|
||||
if 'username' in session :
|
||||
UTILISATEUR='%s' % escape(session['username'])
|
||||
return send_from_directory(
|
||||
os.path.join(DOSSIER_PERSO, UTILISATEUR, 'images/thumbnails'), filename )
|
||||
else :
|
||||
return redirect(url_for('loginlogout.login'))
|
||||
|
||||
@app.route( '/' )
|
||||
def index():
|
||||
if 'username' in session :
|
||||
return redirect(url_for('profil.profile'))
|
||||
else :
|
||||
return redirect(url_for('loginlogout.login', _external=True))
|
||||
app.register_blueprint(mygallery)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def create_app():
|
||||
|
||||
app = Flask( 'pywallter' )
|
||||
app.config.from_pyfile('config.py')
|
||||
bcrypt = Bcrypt(app)
|
||||
|
||||
init_db()
|
||||
db_migrate()
|
||||
if init_dir():
|
||||
print ("Le repertoire des utilisateurs a été créer")
|
||||
|
||||
|
||||
|
||||
DOSSIER_PERSO= app.config['DOSSIER_APP']
|
||||
|
||||
extensionimg = app.config['EXT_IMG']
|
||||
|
||||
|
||||
app.register_blueprint(inscription)
|
||||
app.register_blueprint(postit)
|
||||
app.register_blueprint(filesupload)
|
||||
app.register_blueprint(profil)
|
||||
app.register_blueprint(logs)
|
||||
app.register_blueprint(loginlogout)
|
||||
|
||||
return app
|
||||
|
||||
if __name__ == '__main__' :
|
||||
app.run(host='127.0.0.1', port=8080, debug=True)
|
||||
hostname=gethostname()
|
||||
app.run(host='127.0.0.1', port=8080, debug=False)
|
||||
|
||||
Reference in New Issue
Block a user