1 Commits

Author SHA1 Message Date
nono
2cc0b40b90 Ajout de quelques changements pour acces libre 2025-06-18 11:57:34 +02:00
5 changed files with 10 additions and 10 deletions

View File

@@ -57,16 +57,10 @@ $ export FLASK_APP=src/main.py
$ flask run $ flask run
``` ```
This command should start a web server with which you can test your configuration. If you plan on exposing your printer to the Internet, and give it an IP / URL, _please, please, please_, don't run it this way. Look at Flask's documentation and read about running a production server. It's a little more work, but it will prevent your computer/server being hacked in too easily. This command should start a web server with which you can test your configuration. If you plan on exposing your printer to the Internet, and give it an IP / URL, _please, please, please_, don't run it this way. Look at Flask's documentation and read about running a production server. It's a little more work, but it will prevent your computer/server being hacked in too easily.
Voilà ! Voilà !
## Contributions
Your contributions are very much welcome ! You can either request an account on git.n07070.xyz, or send me a patch by email ( see git-send-mail.io ). Please [squash](https://www.geeksforgeeks.org/git/use-of-git-squash-commits/) yours commits into one commit, and add as much information in the commit's description. The more you add comments and descriptions, the better it is.
Please also say if you had a printer to test your code, and which printer you've been using.
## Screenshots ## Screenshots
![](src/static/images/homepage.png) ![](src/static/images/homepage.png)

View File

@@ -19,6 +19,7 @@ import os # For VARS from the shell.
# Variables # Variables
app = Flask(__name__) app = Flask(__name__)
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif'}
# Load the configuration file # Load the configuration file
try: try:
@@ -44,13 +45,12 @@ try:
os.mkdir(UPLOAD_FOLDER) os.mkdir(UPLOAD_FOLDER)
app.logger.debug(f"Directory '{UPLOAD_FOLDER}' created successfully.") app.logger.debug(f"Directory '{UPLOAD_FOLDER}' created successfully.")
except FileExistsError: except FileExistsError:
app.logger.error(f"Directory '{UPLOAD_FOLDER}' already exists.") app.logger.debug(f"Directory '{UPLOAD_FOLDER}' already exists.")
except PermissionError: except PermissionError:
app.logger.error(f"Permission denied: Unable to create '{UPLOAD_FOLDER}'.") app.logger.error(f"Permission denied: Unable to create '{UPLOAD_FOLDER}'.")
except Exception as e: except Exception as e:
app.logger.error(f"An error occurred: {e}") app.logger.error(f"An error occurred: {e}")
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif'}
# Output the config file # Output the config file
if os.getenv('LIPY_DEBUG') == True: if os.getenv('LIPY_DEBUG') == True:

View File

@@ -125,6 +125,7 @@ class Printer(object):
try: try:
self.printer.open(self.usb_args); 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.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("> Printed by LittlePrinter | https://n07070.xyz/articles/littleprynter")
self.printer.textln(clean_msg) 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.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.textln("> " + clean_signature + " @ " + strftime("%Y-%m-%d %H:%M:%S", gmtime()))
@@ -161,6 +162,7 @@ class Printer(object):
try: try:
self.printer.open(self.usb_args) self.printer.open(self.usb_args)
self.printer.textln("> Printed by LittlePrinter | https://n07070.xyz/articles/littleprynter")
self.printer.textln("> " + clean_signature + " @ " + strftime("%Y-%m-%d %H:%M:%S", gmtime())) self.printer.textln("> " + clean_signature + " @ " + strftime("%Y-%m-%d %H:%M:%S", gmtime()))
self.printer.image(path) self.printer.image(path)
self.printer.cut() self.printer.cut()

4
src/raspberry.py Normal file
View File

@@ -0,0 +1,4 @@
from printer import Printer
class Raspberry(object):
pass

View File

@@ -124,7 +124,7 @@ function print_picture(data){
let time = currentDate.getHours() + ":" + currentDate.getMinutes() + ":" + currentDate.getSeconds(); let time = currentDate.getHours() + ":" + currentDate.getMinutes() + ":" + currentDate.getSeconds();
formData.set("img", picture, "picture.png"); formData.set("img", picture, "picture.png");
formData.set("signature", "Printed via the webcam @ " + time) formData.set("signature", " Accès Libre ~ 1 An ~ Fête de la Musique Libre @ " + time)
fetch(url, { fetch(url, {
method: 'POST', // or 'PUT' method: 'POST', // or 'PUT'