Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
web2print
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Frank Sauerburger
web2print
Commits
28025661
Verified
Commit
28025661
authored
5 years ago
by
Frank Sauerburger
Browse files
Options
Downloads
Patches
Plain Diff
Evaluate 'printer' field
parent
2fedcc2c
No related branches found
No related tags found
1 merge request
!3
Resolve "Improve UX with spinners and dismissible alerts"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
assets/upload.js
+3
-1
3 additions, 1 deletion
assets/upload.js
web2print.py
+8
-5
8 additions, 5 deletions
web2print.py
with
11 additions
and
6 deletions
assets/upload.js
+
3
−
1
View file @
28025661
...
...
@@ -39,7 +39,9 @@ function uploadFile(file) {
$
(
"
#dropzone
"
).
addClass
(
"
drop-uploading
"
);
let
formData
=
new
FormData
();
formData
.
append
(
'
document
'
,
file
)
formData
.
append
(
'
document
'
,
file
);
formData
.
append
(
'
printer
'
,
$
(
"
#printer
"
).
val
());
fetch
(
"
/
"
,
{
method
:
'
POST
'
,
body
:
formData
...
...
This diff is collapsed.
Click to expand it.
web2print.py
+
8
−
5
View file @
28025661
...
...
@@ -5,9 +5,6 @@ import cups
from
flask
import
Flask
,
render_template
,
request
,
send_from_directory
from
werkzeug.utils
import
secure_filename
CUPS_SERVER
=
"
10.1.9.104:631
"
cups
.
setServer
(
CUPS_SERVER
)
app
=
Flask
(
__name__
)
app
.
config
[
'
UPLOAD_FOLDER
'
]
=
"
/tmp/web2print
"
os
.
makedirs
(
"
/tmp/web2print
"
,
exist_ok
=
True
)
...
...
@@ -23,16 +20,22 @@ def get_printers():
@app.route
(
'
/
'
,
methods
=
[
"
POST
"
,
"
GET
"
])
def
index
():
if
(
request
.
method
==
"
GET
"
)
or
(
"
document
"
not
in
request
.
files
)
or
\
(
not
request
.
files
[
"
document
"
].
filename
):
(
not
request
.
files
[
"
document
"
].
filename
)
or
\
(
"
printer
"
not
in
request
.
form
)
or
(
not
request
.
form
[
"
printer
"
]):
return
render_template
(
"
index.html
"
,
printers
=
printers
)
printer
=
request
.
form
[
"
printer
"
]
if
printer
not
in
printers
:
printer
=
printers
[
0
]
file
=
request
.
files
[
'
document
'
]
filename
=
secure_filename
(
file
.
filename
)
local_path
=
os
.
path
.
join
(
app
.
config
[
'
UPLOAD_FOLDER
'
],
filename
)
file
.
save
(
local_path
)
conn
=
cups
.
Connection
()
conn
.
printFile
(
printer
s
[
0
]
,
local_path
,
"
web2print-%d
"
%
time
(),
conn
.
printFile
(
printer
,
local_path
,
"
web2print-%d
"
%
time
(),
{
"
fit-to-page
"
:
"
True
"
,
"
sides
"
:
"
two-sided-long-edge
"
})
try
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment