Wow!!!
This commit is contained in:
parent
1fbefd13b2
commit
fe965840d7
|
@ -1,15 +0,0 @@
|
|||
https://youtu.be/O4xNJsjtN6E
|
||||
|
||||
https://youtu.be/6KfJXl-Kvws
|
||||
|
||||
dV1M7Z5int2+QgRtDrQJRedIk+6lp3O8GoVBOzvq9zNUsIT7yvz43duMKygPZw== (64)
|
||||
dV1M7Z5int2+QgRtDrQJRedIk+6lp3O8GoVBOzvq
|
||||
9zNUsIT7yvz43duMKygPZw== (F7 33 54 B0 84 FB CA FC F8 DD DB 8C 2B 28 0F 67)
|
||||
|
||||
1~15 : 24
|
||||
16~31 : 44
|
||||
/!\ --->{32~47 : 64}<--- /!\
|
||||
|
||||
01110101 01011101 01001100 11101101 10011110 01100010 10011110 11011101 10111110 01000010 00000100 01101101 00001110 10110100 00001001 01000101 11100111 01001000 10010011 11101110 10100101 10100111 01110011 10111100 00011010 10000101 01000001 00111011 00111011 11101010 11110111 00110011 01010100 10110000 10000100 11111011 11001010 11111100 11111000 11011101 11011011 10001100 00101011 00101000 00001111 01100111
|
||||
|
||||
dV1M7Z5int2+QgRtDrQJRedIk+6lp3O8GoVBOzvq9zNUsIT7yvz43duMKygPZw==
|
|
@ -1,15 +0,0 @@
|
|||
https://youtu.be/O4xNJsjtN6E
|
||||
|
||||
https://youtu.be/6KfJXl-Kvws
|
||||
|
||||
dV1M7Z5int2+QgRtDrQJRedIk+6lp3O8GoVBOzvq9zNUsIT7yvz43duMKygPZw== (64)
|
||||
dV1M7Z5int2+QgRtDrQJRedIk+6lp3O8GoVBOzvq
|
||||
9zNUsIT7yvz43duMKygPZw== (F7 33 54 B0 84 FB CA FC F8 DD DB 8C 2B 28 0F 67)
|
||||
|
||||
1~15 : 24
|
||||
16~31 : 44
|
||||
/!\ --->{32~47 : 64}<--- /!\
|
||||
|
||||
01110101 01011101 01001100 11101101 10011110 01100010 10011110 11011101 10111110 01000010 00000100 01101101 00001110 10110100 00001001 01000101 11100111 01001000 10010011 11101110 10100101 10100111 01110011 10111100 00011010 10000101 01000001 00111011 00111011 11101010 11110111 00110011 01010100 10110000 10000100 11111011 11001010 11111100 11111000 11011101 11011011 10001100 00101011 00101000 00001111 01100111
|
||||
|
||||
dV1M7Z5int2+QgRtDrQJRedIk+6lp3O8GoVBOzvq9zNUsIT7yvz43duMKygPZw==
|
|
@ -3,12 +3,14 @@ from config import Config
|
|||
from flask_sqlalchemy import SQLAlchemy
|
||||
from flask_migrate import Migrate
|
||||
from flask_login import LoginManager
|
||||
from flask_wtf.csrf import CSRFProtect
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config.from_object(Config)
|
||||
db = SQLAlchemy(app)
|
||||
migrate = Migrate(app, db)
|
||||
login = LoginManager(app)
|
||||
csrf = CSRFProtect(app)
|
||||
|
||||
# There is the dictionnary, which can be usefull when you want to change the language.
|
||||
words = {
|
||||
|
@ -16,6 +18,7 @@ words = {
|
|||
'nameHome' : 'Home',
|
||||
'nameUpload' : 'Upload',
|
||||
'nameLogin' : 'Login',
|
||||
'nameView' : 'View',
|
||||
'nameRegister' : 'Register',
|
||||
'termLogout' : 'Logout',
|
||||
'termChoose' : 'Choose a directory',
|
||||
|
@ -27,7 +30,8 @@ words = {
|
|||
'termIsAdmin' : 'Is Admin?',
|
||||
'termRegistered' : 'Registered: ',
|
||||
'ErrorInvalid' : 'Invalid Password or Username',
|
||||
'ErrorUsername' : 'Username already used'
|
||||
'ErrorUsername' : 'Username already used',
|
||||
'ErrorNoFiles' : 'There is no files which belong to this user'
|
||||
}
|
||||
|
||||
from app import routes, models
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -13,7 +13,7 @@ from app.models import User, File
|
|||
# Parameters:
|
||||
# 'page.html'
|
||||
# dico=words (Usefull to translate all the site with one dictionary)
|
||||
# userloged=current_user (Usefull to know if the user is logged in, and if yes, his name)
|
||||
# userlogged=current_user (Usefull to know if the user is logged in, and if yes, his name)
|
||||
# title='title' (Optional: If you want to change the title of the page, You can also use words['pageTitle'] to change faster when you want to translate)
|
||||
|
||||
# Home page
|
||||
|
@ -21,7 +21,7 @@ from app.models import User, File
|
|||
@app.route('/')
|
||||
@app.route('/home')
|
||||
def home():
|
||||
return render_template('home.html', title=words['nameHome'], dico=words, userloged=current_user)
|
||||
return render_template('home.html', title=words['nameHome'], dico=words, userlogged=current_user)
|
||||
|
||||
# Login page
|
||||
# Use it to login
|
||||
|
@ -38,7 +38,7 @@ def login():
|
|||
return redirect(url_for('login'))
|
||||
login_user(user, remember=form.remember_me.data)
|
||||
return redirect(url_for('home'))
|
||||
return render_template('login.html', title=words['nameLogin'], dico=words, form=form, userloged=current_user)
|
||||
return render_template('login.html', title=words['nameLogin'], dico=words, form=form, userlogged=current_user)
|
||||
|
||||
# Logout page
|
||||
# Use it to logout
|
||||
|
@ -66,7 +66,7 @@ def register():
|
|||
os.mkdir(os.path.join(app.config['FILES_DIR'], form.username.data))
|
||||
flash(words['termRegistered'] + form.username.data)
|
||||
return redirect(url_for('home'))
|
||||
return render_template('register.html', title=words['nameRegister'], dico=words, form=form, userloged=current_user)
|
||||
return render_template('register.html', title=words['nameRegister'], dico=words, form=form, userlogged=current_user)
|
||||
|
||||
# Upload page
|
||||
# Use it to upload a file
|
||||
|
@ -86,9 +86,9 @@ def upload():
|
|||
db.session.add(filetodb)
|
||||
db.session.commit()
|
||||
return redirect(url_for('home'))
|
||||
return render_template('upload.html', title=words['nameUpload'], dico=words, form=form, userloged=current_user)
|
||||
return render_template('upload.html', title=words['nameUpload'], dico=words, form=form, userlogged=current_user)
|
||||
|
||||
# Users' download pages
|
||||
# Download pages
|
||||
# Use it to download a file
|
||||
# Redirect automatically to the home page if the user isn't logged in
|
||||
# If the id is'nt reconized, redirect automatically to the home page
|
||||
|
@ -103,4 +103,36 @@ def download(id):
|
|||
if filetodb.user == current_user or current_user.isAdmin == True:
|
||||
return send_from_directory(os.path.join(app.config['FILES_DIR'], filetodb.user.username), filetodb.name, as_attachment=True)
|
||||
else:
|
||||
return redirect(url_for('home'))
|
||||
return redirect(url_for('home'))
|
||||
|
||||
# Users' View Page
|
||||
# It will show all files which belong to the requested user
|
||||
# Redirect automatically to the home page if the user isn't logged in or is an Admin
|
||||
@app.route('/view')
|
||||
def viewUser():
|
||||
if not current_user.is_authenticated:
|
||||
return redirect(url_for('home'))
|
||||
if current_user.isAdmin:
|
||||
return redirect(url_for('home'))
|
||||
|
||||
# Admins' View Page
|
||||
# It will show all files which belong to the requested user
|
||||
# Redirect automatically to the home page if the user isn't logged in or isn't an Admin
|
||||
# If the id is'nt reconized, redirect automatically to the home page
|
||||
@app.route('/view/<id>')
|
||||
def viewAdmin(id):
|
||||
if not current_user.is_authenticated:
|
||||
return redirect(url_for('home'))
|
||||
if not current_user.isAdmin:
|
||||
return redirect(url_for('home'))
|
||||
user = User.query.filter_by(id=id).first()
|
||||
if not user:
|
||||
return redirect(url_for('home'))
|
||||
files = []
|
||||
for filefromdb in File.query.all():
|
||||
if filefromdb.user == user:
|
||||
files.append(filefromdb)
|
||||
if not len(files):
|
||||
flash(words['ErrorNoFiles'])
|
||||
return redirect(url_for('home'))
|
||||
return render_template('view.html', title=words['nameView'] + ' - ' + user.username, dico=words, userlogged=current_user, files=files)
|
|
@ -10,16 +10,16 @@
|
|||
<div>
|
||||
{{ dico['nameApp'] }}
|
||||
<a href="{{ url_for('home') }}">{{ dico['nameHome'] }}</a>
|
||||
{% if userloged.is_authenticated == False %}
|
||||
{% if userlogged.is_authenticated == False %}
|
||||
<a href="{{ url_for('login') }}">{{ dico['nameLogin'] }}</a>
|
||||
{% else %}
|
||||
<a href="{{ url_for('upload') }}">{{ dico['nameUpload'] }}</a>
|
||||
{% if userloged.isAdmin == True %}
|
||||
{% if userlogged.isAdmin == True %}
|
||||
<a href="{{ url_for('register') }}">{{ dico['nameRegister'] }}</a>
|
||||
{% endif %}
|
||||
<a href="{{ url_for('logout') }}">{{ dico['termLogout'] }}</a>
|
||||
{% endif %}
|
||||
{{ userloged.username }}
|
||||
{{ userlogged.username }}
|
||||
<hr>
|
||||
{% with messages = get_flashed_messages() %}
|
||||
{% if messages %}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
{% for file in files %}
|
||||
<div>
|
||||
<a href="{{ url_for('download', id=file.id)}}">| {{ file.name }}, {{ file.user.username }} |</a>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
Loading…
Reference in New Issue