2023-07-14 21:42:29 +08:00
|
|
|
import os
|
|
|
|
|
2023-07-14 15:12:10 +08:00
|
|
|
import falcon
|
|
|
|
|
2023-07-14 21:42:29 +08:00
|
|
|
from .images import Collection, Item, ImageStore
|
|
|
|
|
|
|
|
|
|
|
|
def create_app(image_store):
|
|
|
|
app = falcon.App()
|
|
|
|
app.add_route('/images', Collection(image_store))
|
|
|
|
app.add_route('/images/{name}', Item(image_store))
|
|
|
|
return app
|
|
|
|
|
2023-07-14 15:12:10 +08:00
|
|
|
|
2023-07-14 21:42:29 +08:00
|
|
|
def get_app():
|
|
|
|
storage_path = os.environ.get('LOOK_STORAGE_PATH', './images')
|
|
|
|
image_store = ImageStore(storage_path)
|
|
|
|
return create_app(image_store)
|
2023-07-14 15:12:10 +08:00
|
|
|
|