Giter Site home page Giter Site logo

dlazesz / driverless-print-and-scan Goto Github PK

View Code? Open in Web Editor NEW
15.0 2.0 2.0 22 KB

Simple REST API for driverless printing (IPP or CUPS) and scanning (eSCL) for network printers and scanners

License: GNU Lesser General Public License v3.0

Python 100.00%

driverless-print-and-scan's Introduction

Driverless Printing and Scanning REST API

A simple REST API for scanning (eSCL) to JPEG or PDF and printing (with IPP or CUPS) a PDF from anywhere (eg. via a webbrowser) with ease

Motivation

I could not find a simple web app running on a server that could initiate a printing and scanning process from other machines without installing anything on the client machines. So I had to write my own on top of almost 10 years old standards (IPP and eSCL)... Et voilà!

Motto:

"So tonight I'm gonna print and scan like it's nineteen ninety-nine!" (refering to Prince)

Requirements

  • Python 3
  • A server (ipptool in PATH or CUPS with the printer driver properly installed)
  • An IPP capable printer and/or an eSCL capable scanner
  • A WSGI server

Example setup

  1. Setup your printer in CUPS on the server (if the CUPS option is chosen)
  2. Make a virtual environment: sudo virtualenv -p python3 /var/www/driverless_print_and_scan_venv
  3. Clone the repository: sudo git clone https://github.com/dlazesz/driverless_print_and_scan_venv/driverless-print-and-scan
  4. Modify the PRINTER variable in printrest.py to the appropriate name and SCANNER_IP variable in scanrest.py
  5. Install requirements in the virtual environment source /var/www/driverless_print_and_scan_venv/bin/activate; pip install -r requirements.txt
  6. Set user permissions: sudo chown -R user:www-data /var/www/driverless_print_and_scan_venv
  7. Create the WSGI file:
    from printrest import app
    
    if __name__ == '__main__':
        app.run()
  8. Setup a WSGI server. I do not recommend uwsgi because of its numerous quirks
    • Example in apache:
      <VirtualHost *:80>
      
          WSGIDaemonProcess printrest threads=5 python-path=/var/www/printrest_venv/lib/python3.5/site-packages
          WSGIScriptAlias /print /var/www/printrest_venv/printREST/print.wsgi
      
          <Directory /var/www/printrest_venv/printREST>
              WSGIProcessGroup printrest
              WSGIApplicationGroup %{GLOBAL}
              Order deny,allow
              Allow from all
          </Directory>
      </VirtualHost>
    • Example in Gunicorn + Nginx + Systemd:
      • Create Systemd unit sudo mcedit /etc/systemd/system/printREST.service with the following content:
        [Unit]
        Description=Gunicorn instance to serve printREST
        After=network.target
        
        [Service]
        User=sammy
        Group=www-data
        WorkingDirectory=/var/www/driverless_print_and_scan_venv/driverless-print-and-scan
        Environment="PATH=/var/www/driverless_print_and_scan_venv/bin"
        ExecStart=/var/www/driverless_print_and_scan_venv/bin/gunicorn --workers 2 --bind unix:printREST.sock -m 007 wsgi:app
        
        [Install]
        WantedBy=multi-user.target
      • Start and enable the Systemd service sudo systemctl start printREST && sudo systemctl enable printREST
      • Add location to Nginx:
        location /print {
            # Do not forget to add password protection!
            include proxy_params;
            proxy_pass http://unix:/var/www/driverless_print_and_scan_venv/driverless-print-and-scan/printREST.sock;
            client_max_body_size 100M;  # 1MB is the default upload limit! 
        }
        
      • Restart Nginx sudo systemctl restart nginx
  9. Navigate to http://yourserver.com/print
  10. Print from anywhere to your printer without installing drivers
  11. Profit!

The same goes for the scanner setup

License

This program is licensed under the LGPL 3.0 license.

driverless-print-and-scan's People

Contributors

dlazesz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

waglpz karnauskas

driverless-print-and-scan's Issues

Issues with setup/installation

  1. "sudo git clone https://github.com/dlazesz/driverless_print_and_scan_venv/driverless-print-and-scan" fails with "repository does not exist". https://github.com/dlazesz/driverless-print-and-scan.git does not appear to have the proper files to support setting up the virtualenv, i.e, /var/www/driverless_print_and_scan_venv/bin/activate
  2. Is it correct to assume that "Step 7: Create the WSGI file:" refers to /var/www/driverless_print_and_Scan_venv/printREST.py ?
  3. Is it correct to assume that "Add location to Nginx:" refers to /etc/nginx/nginx.conf?

Thank you for your time and efforts.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.