server.py 910 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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')
  15. # Legacy endpoint. @TODO Deprecate.
  16. fcrepo.register_blueprint(ldp, url_prefix='/rest')
  17. fcrepo.register_blueprint(query, url_prefix='/query')
  18. ## ROUTES ##
  19. @fcrepo.route('/', methods=['GET'])
  20. def index():
  21. '''
  22. Homepage.
  23. '''
  24. return render_template('index.html')
  25. @fcrepo.route('/debug', methods=['GET'])
  26. def debug():
  27. '''
  28. Debug page.
  29. '''
  30. raise RuntimeError()