Compare commits
6 Commits
bb7e12a561
...
5b28213075
Author | SHA1 | Date | |
---|---|---|---|
5b28213075 | |||
e82672b8cb | |||
4fea7c1e86 | |||
be3770956c | |||
5a0cc6011b | |||
81a99b6a80 |
3
run.sh
Executable file
3
run.sh
Executable file
@ -0,0 +1,3 @@
|
||||
export FLASK_APP=src/main.py
|
||||
export FLASK_ENV=development
|
||||
flask run --host 192.168.0.42 --debugger --eager-loading
|
@ -87,7 +87,11 @@ def api_print_sms():
|
||||
flash(e)
|
||||
redirect(url_for('index'))
|
||||
|
||||
flash(web.print_sms(txt,sign))
|
||||
try:
|
||||
web.print_sms(txt,sign)
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
return redirect(url_for('index'))
|
||||
|
||||
@app.route('/api/print/image', methods=['POST'])
|
||||
|
@ -120,13 +120,17 @@ class Printer(object):
|
||||
return False
|
||||
|
||||
if not os.getenv('LIPY_DEBUG') == True:
|
||||
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()
|
||||
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)
|
||||
|
||||
flash("Message printed : " + clean_msg ,category='info')
|
||||
return True
|
||||
|
||||
|
0
src/templates/footer.html
Normal file
0
src/templates/footer.html
Normal file
0
src/templates/header.html
Normal file
0
src/templates/header.html
Normal file
@ -12,11 +12,12 @@
|
||||
<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-warning" role="alert">{{ message }}</div>
|
||||
<div class="alert alert-danger" role="alert">{{ message }}</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
@ -54,7 +55,7 @@
|
||||
<br>
|
||||
<br>
|
||||
<hr>
|
||||
<footer>Little Prynter is built for fun by <a href="https://n07070.xyz/about-me/">n07070</a> for fun :) </footer>
|
||||
<footer>Little Prynter is built by <a href="https://n07070.xyz/about-me/">n07070</a> for fun :) </footer>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
0
src/templates/login.html
Normal file
0
src/templates/login.html
Normal file
0
src/templates/print.html
Normal file
0
src/templates/print.html
Normal file
33
src/user.py
33
src/user.py
@ -4,3 +4,36 @@ 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))
|
||||
self.app.logger.debug("Printing : " + str(texte) + " from " + str(sign))
|
||||
if not os.getenv('LIPY_DEBUG'):
|
||||
time.sleep(10)
|
||||
time.sleep(1)
|
||||
|
||||
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