Compare commits
No commits in common. "99666d40d68538a2d11decaad4afa92e26743c69" and "e1780fad993ef8d3aad5fe9681966c43e1bf120a" have entirely different histories.
99666d40d6
...
e1780fad99
@ -1,8 +0,0 @@
|
||||
import json
|
||||
|
||||
with open("server-rx.json", 'r', encoding = "utf-8") as file:
|
||||
server_data = json.load(file)
|
||||
|
||||
bind = f"{server_data['ip']}:{server_data['port']}"
|
||||
workers = 2
|
||||
timeout = 120
|
@ -1,9 +0,0 @@
|
||||
blinker==1.9.0
|
||||
click==8.1.8
|
||||
Flask==3.1.0
|
||||
gunicorn==23.0.0
|
||||
itsdangerous==2.2.0
|
||||
Jinja2==3.1.5
|
||||
MarkupSafe==3.0.2
|
||||
packaging==24.2
|
||||
Werkzeug==3.1.3
|
@ -1,5 +0,0 @@
|
||||
{
|
||||
"ip": "127.0.0.1",
|
||||
"port": 33333,
|
||||
"secret": "PROJECT_BY_GAZAKBAYEV_AHMET"
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
import os
|
||||
import json
|
||||
|
||||
from flask import Flask, request
|
||||
|
||||
app = Flask(__name__)
|
||||
SECRET = None
|
||||
|
||||
with open("server-rx.json", 'r', encoding = "utf-8") as file:
|
||||
server_data = json.load(file)
|
||||
SECRET = server_data['secret']
|
||||
|
||||
def go_to_print(file_path, samples):
|
||||
os.system(f"lp -n {samples} {file_path}")
|
||||
|
||||
@app.route('/printfile', methods=['POST'])
|
||||
def print_file():
|
||||
if 'file' not in request.files:
|
||||
return 'Файл не был предоставлен.', 400
|
||||
if 'secret-key' not in request.form:
|
||||
return 'Секретный ключ не был предоставлен.', 400
|
||||
if request.form['secret-key'] != SECRET:
|
||||
return 'Авторизация не удалась.', 400
|
||||
file = request.files['file']
|
||||
filename = "files/" + file.filename
|
||||
with open(filename, 'wb') as f:
|
||||
f.write(file.read())
|
||||
samples = 1
|
||||
if b'samples' in request.data:
|
||||
samples = request.data[b'samples']
|
||||
try:
|
||||
go_to_print(filename, samples)
|
||||
return 'Файл отправлен на печать.', 200
|
||||
except Exception as e:
|
||||
return f'Ошибка при печати файла: {str(e)}.', 500
|
||||
finally:
|
||||
return 'OK', 200
|
Loading…
x
Reference in New Issue
Block a user