A Python content management system designed for kirsle.net featuring a blog, comments and photo albums. https://rophako.kirsle.net/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

runserver.py 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. from __future__ import unicode_literals
  4. import sys
  5. import argparse
  6. from rophako.app import app
  7. parser = argparse.ArgumentParser(description="Rophako")
  8. parser.add_argument(
  9. "--port", "-p",
  10. type=int,
  11. help="Port to listen on",
  12. default=2006,
  13. )
  14. parser.add_argument(
  15. "--key", "-k",
  16. type=str,
  17. help="SSL private key file. Providing this option will turn on SSL mode " \
  18. + "(and will require pyOpenSSL to be installed).",
  19. )
  20. parser.add_argument(
  21. "--cert", "-c",
  22. type=str,
  23. help="SSL certificate file.",
  24. )
  25. parser.add_argument(
  26. "--production",
  27. help="Turns off debug mode, runs as if in production.",
  28. action="store_true",
  29. )
  30. args = parser.parse_args()
  31. if __name__ == '__main__':
  32. flask_options = dict(
  33. host='0.0.0.0',
  34. debug=not args.production,
  35. port=args.port,
  36. threaded=True,
  37. )
  38. if args.key and args.cert:
  39. from OpenSSL import SSL
  40. context = SSL.Context(SSL.SSLv23_METHOD)
  41. context.use_privatekey_file(args.key)
  42. context.use_certificate_file(args.cert)
  43. app.config['SESSION_COOKIE_SECURE'] = True
  44. flask_options["ssl_context"] = context
  45. app.run(**flask_options)