Skip to content

Commit

Permalink
[IMP] Enable SSL/TLS support
Browse files Browse the repository at this point in the history
  • Loading branch information
andreparames authored and Pierrick Brun committed Mar 4, 2020
1 parent 5ddafdf commit 003bacd
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion pywebdriverd
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
import os

from pywebdriver import app, config, drivers

Expand All @@ -9,7 +10,28 @@ def main():
if config.getboolean('application', 'print_status_start'):
if 'escpos' in drivers:
drivers['escpos'].push_task('printstatus')
app.run(host=host, port=port, debug=debug)
flask_args = dict(
host=host,
port=port,
debug=debug,
processes=0,
threaded=True
)
if config.has_option('flask', 'sslcert'):
sslcert = config.get('flask', 'sslcert')
if sslcert:
if not config.has_option('flask', 'sslkey'):
print("If you want SSL, you must also provide the sslkey")
sys.exit(-1)
sslkey = config.get('flask', 'sslkey')
if not os.path.exists(sslcert):
print("SSL cert not found at", sslcert)
sys.exit(-1)
if not os.path.exists(sslkey):
print("SSL key not found at", sslkey)
sys.exit(-1)
flask_args['ssl_context'] = (sslcert, sslkey)
app.run(**flask_args)

# Run application
if __name__ == '__main__':
Expand Down

0 comments on commit 003bacd

Please sign in to comment.