__init__.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/usr/bin/env python
  2. """
  3. Copyright (C) 2014, Paul Munday.
  4. PO Box 28228, Portland, OR, USA 97228
  5. paul at paulmunday.net
  6. This program is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. There should also be a copy of the GPL in src/license.md that should be accessib
  17. le by going to <a href ="/license">/license<a> on this site.
  18. As originally distributed this program will be able to display its own source co
  19. de, which may count as conveying under the terms of the GPL v3. You should there
  20. fore make sure the copy of the GPL (i.e. src/license.md) is left in place.
  21. You are also free to remove this section from the code as long as any modified c
  22. opy you distribute (including a copy that is unchanged except for removal of thi
  23. s feature) is also licensed under the GPL version 3 (or later versions).
  24. None of this means you have to license your own content this way, only the origi
  25. nal source code and any modifications, or any subsequent additions that have bee
  26. n explicitly licensed under the GPL version 3 or later.
  27. You are therefore free to add templates and style sheets under your own terms th
  28. ough I would be happy if you chose to license them in the same way.
  29. """
  30. from flask import Flask
  31. import sys
  32. app = Flask(__name__)
  33. from monomotapa import views
  34. from monomotapa.config import Config, ConfigError
  35. from monomotapa.pparams import DEVELOPMENT, DEPLOYMENT, CONFIG_FILE
  36. from monomotapa.pparams import CLAVE1, CLAVE2, CARPETA_BACKUPS
  37. # filtros personalizados para jinja
  38. from monomotapa.filters import titulo_desdeNombrePost
  39. app.jinja_env.filters['n_heading'] = titulo_desdeNombrePost
  40. # The name of the file not the path
  41. # It look for it in CWD, the apps main dir, /etc/monomatapa /etc in that order
  42. CONFIG = Config(CONFIG_FILE)
  43. try:
  44. app.debug = CONFIG.config['debug']
  45. except KeyError:
  46. app.debug = False
  47. try:
  48. app.config['enable_unit_tests'] = CONFIG.config['enable_unit_tests']
  49. except KeyError:
  50. app.config['enable_unit_tests'] = False
  51. try:
  52. app.config['default_title'] = CONFIG.config['default_title']
  53. except KeyError:
  54. app.config['default_title'] = None