server.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import logging
  2. import os
  3. from logging.config import dictConfig
  4. from flask import Flask, render_template
  5. from lakesuperior.config_parser import config
  6. from lakesuperior.endpoints.ldp import ldp
  7. from lakesuperior.endpoints.query import query
  8. fcrepo = Flask(__name__)
  9. fcrepo.config.update(config['flask'])
  10. dictConfig(config['logging'])
  11. logger = logging.getLogger(__name__)
  12. logger.info('Starting LAKEsuperior HTTP server.')
  13. ## Configure enpoint blueprints here. ##
  14. fcrepo.register_blueprint(ldp, url_prefix='/ldp', url_defaults={
  15. 'url_prefix': 'ldp'
  16. })
  17. # Legacy endpoint. @TODO Deprecate.
  18. fcrepo.register_blueprint(ldp, url_prefix='/rest', url_defaults={
  19. 'url_prefix': 'rest'
  20. })
  21. fcrepo.register_blueprint(query, url_prefix='/query')
  22. # Initialize temporary folders.
  23. tmp_path = config['application']['store']['ldp_nr']['path'] + '/tmp'
  24. if not os.path.exists(tmp_path):
  25. os.makedirs(tmp_path)
  26. ## ROUTES ##
  27. @fcrepo.route('/', methods=['GET'])
  28. def index():
  29. '''
  30. Homepage.
  31. '''
  32. return render_template('index.html')
  33. @fcrepo.route('/debug', methods=['GET'])
  34. def debug():
  35. '''
  36. Debug page.
  37. '''
  38. raise RuntimeError()