server.py 792 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import io
  2. import json
  3. import os.path
  4. from flask import Flask
  5. from lakesuperior.config_parser import config
  6. from lakesuperior.ldp.resource import Resource
  7. app = Flask(__name__)
  8. app.config.update(config['flask'])
  9. @app.route('/', methods=['GET'])
  10. def index():
  11. '''Homepage'''
  12. return 'Hello. This is LAKEsuperior.'
  13. @app.route('/<uuid>', methods=['GET'])
  14. def get_resource():
  15. '''Add a new resource in a new URI.'''
  16. rsrc = Resource.get(uuid)
  17. return rsrc.path
  18. @app.route('/<path>', methods=['POST'])
  19. def post_resource():
  20. '''Add a new resource in a new URI.'''
  21. rsrc = Resource.post(path)
  22. return rsrc.path
  23. @app.route('/<path>', methods=['PUT'])
  24. def put_resource():
  25. '''Add a new resource in a new URI.'''
  26. rsrc = Resource.put(path)
  27. return rsrc.path