Compare commits
No commits in common. "5b28213075db5bafe5705c893ac221c24d2708bb" and "bb7e12a5618a5a741011d64bf8601b8a09c42453" have entirely different histories.
5b28213075
...
bb7e12a561
3
run.sh
3
run.sh
@ -1,3 +0,0 @@
|
||||
export FLASK_APP=src/main.py
|
||||
export FLASK_ENV=development
|
||||
flask run --host 192.168.0.42 --debugger --eager-loading
|
@ -87,11 +87,7 @@ def api_print_sms():
|
||||
flash(e)
|
||||
redirect(url_for('index'))
|
||||
|
||||
try:
|
||||
web.print_sms(txt,sign)
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
flash(web.print_sms(txt,sign))
|
||||
return redirect(url_for('index'))
|
||||
|
||||
@app.route('/api/print/image', methods=['POST'])
|
||||
|
@ -120,17 +120,13 @@ class Printer(object):
|
||||
return False
|
||||
|
||||
if not os.getenv('LIPY_DEBUG') == True:
|
||||
try:
|
||||
self.printer.open(self.usb_args);
|
||||
self.printer.set(align='left', font='a', bold=False, underline=0, width=1, height=1, density=8, invert=False, smooth=True, flip=False, double_width=False, double_height=False, custom_size=False)
|
||||
self.printer.textln(clean_msg)
|
||||
self.printer.set(align='left', font='b', bold=False, underline=1, width=1, height=1, density=9, invert=False, smooth=True, flip=False, double_width=False, double_height=False, custom_size=False)
|
||||
self.printer.textln("> " + clean_signature + " @ " + strftime("%Y-%m-%d %H:%M:%S", gmtime()))
|
||||
self.printer.cut()
|
||||
self.printer.close
|
||||
except Exception as e:
|
||||
flash("Unable to print because : " + e)
|
||||
|
||||
self.printer.open(self.usb_args);
|
||||
self.printer.set(align='left', font='a', bold=False, underline=0, width=1, height=1, density=8, invert=False, smooth=True, flip=False, double_width=False, double_height=False, custom_size=False)
|
||||
self.printer.textln(clean_msg)
|
||||
self.printer.set(align='left', font='b', bold=False, underline=1, width=1, height=1, density=9, invert=False, smooth=True, flip=False, double_width=False, double_height=False, custom_size=False)
|
||||
self.printer.textln("> " + clean_signature + " @ " + strftime("%Y-%m-%d %H:%M:%S", gmtime()))
|
||||
self.printer.cut()
|
||||
self.printer.close()
|
||||
flash("Message printed : " + clean_msg ,category='info')
|
||||
return True
|
||||
|
||||
|
@ -12,12 +12,11 @@
|
||||
<div class="col-md-6 offset-md-3">
|
||||
<img class="rounded" width="100px" src="{{ url_for('static', filename='images/little-printer.png') }}" alt="LittlePrynter icon"><h1 class="card-title font-weight-bold">Little Prynter</h1>
|
||||
<hr>
|
||||
<div class="alert alert-dark" role="alert">LittlePrynter is under heavy developpement, you may encounter bugs ! If so, try again. Thanks !</div>
|
||||
<br>
|
||||
{% with messages = get_flashed_messages(category_filter=('error')) %}
|
||||
{% if messages %}
|
||||
{% for message in messages %}
|
||||
<div class="alert alert-danger" role="alert">{{ message }}</div>
|
||||
<div class="alert alert-warning" role="alert">{{ message }}</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
@ -55,7 +54,7 @@
|
||||
<br>
|
||||
<br>
|
||||
<hr>
|
||||
<footer>Little Prynter is built by <a href="https://n07070.xyz/about-me/">n07070</a> for fun :) </footer>
|
||||
<footer>Little Prynter is built for fun by <a href="https://n07070.xyz/about-me/">n07070</a> for fun :) </footer>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
33
src/user.py
33
src/user.py
@ -4,36 +4,3 @@ class User(object):
|
||||
def __init__(self, arg):
|
||||
super(User, self).__init__()
|
||||
self.arg = arg
|
||||
|
||||
# @app.route('/login', methods=['POST','GET'])
|
||||
# @limiter.limit("100 per minute", error_message=error_handler_limiter)
|
||||
def login():
|
||||
if request.method == 'POST':
|
||||
if not session.get('logged_in'):
|
||||
if request.form['username'] and request.form['password']:
|
||||
# Get the json
|
||||
with open('users.json') as f:
|
||||
users_file = json.load(f)
|
||||
for user in users_file["users"]:
|
||||
if users_file["users"][user] == request.form['password']:
|
||||
session['logged_in'] = True
|
||||
session['user'] = request.form['username']
|
||||
|
||||
if not session.get('logged_in'):
|
||||
flash('Mot de passe ou pseudo invalide.','danger')
|
||||
return redirect(url_for('login'))
|
||||
else:
|
||||
return redirect(url_for('display_index_page'))
|
||||
else:
|
||||
flash('Incorrect logins')
|
||||
return render_template('password.html')
|
||||
else:
|
||||
return render_template('password.html')
|
||||
else:
|
||||
return render_template('password.html')
|
||||
|
||||
@app.route("/logout")
|
||||
def logout():
|
||||
session['logged_in'] = False
|
||||
flash('Tu est déconnecté', 'info')
|
||||
return redirect(url_for('login'))
|
||||
|
@ -13,15 +13,15 @@ class Web(object):
|
||||
|
||||
def print_sms(self, texte, sign: str):
|
||||
# TODO: verify the texte before printing it here ?
|
||||
self.app.logger.debug("Printing : " + str(texte) + " from " + str(sign))
|
||||
self.app.logger.debug("Printing : " + str(texte))
|
||||
if not os.getenv('LIPY_DEBUG'):
|
||||
time.sleep(1)
|
||||
time.sleep(10)
|
||||
|
||||
return self.printer.print_sms(texte, sign)
|
||||
|
||||
def print_image(self, image):
|
||||
pass
|
||||
|
||||
|
||||
def login(username: str,password: str) -> bool:
|
||||
pass
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user