deployment ready?
This commit is contained in:
@@ -21,10 +21,10 @@ import environ
|
||||
env = environ.Env(
|
||||
# set casting, default value
|
||||
DEBUG=(bool, False),
|
||||
pages_root=(str,'data_sample'),
|
||||
pages_root=(str,'../data'),
|
||||
static_root=(str,'static'),
|
||||
default_template=(str, 'page.html'),
|
||||
url_prefix =(str, "/stuff"),
|
||||
default_template=(str, 'gallery.html'),
|
||||
url_prefix =(str, "/fotos"),
|
||||
FLATPAGES_EXTENSION = (str, ".md"),
|
||||
FLATPAGES_AUTO_RELOAD = (bool, True)
|
||||
|
||||
@@ -32,12 +32,14 @@ env = environ.Env(
|
||||
# Initialize application
|
||||
app = Flask(__name__)
|
||||
#app.config.update(cfg)
|
||||
app.config["pages_root"]=env('pages_root')
|
||||
app.config["pages_root"]=os.path.abspath(env('pages_root'))
|
||||
app.config["static_root"]=env('static_root')
|
||||
app.config["default_template"]=env('default_template')
|
||||
app.config["FLATPAGES_DEFAULT_TEMPLATE"]=env('default_template')
|
||||
app.config["url_prefix"]=env('url_prefix')
|
||||
app.config["FLATPAGES_EXTENSION"]=env('FLATPAGES_EXTENSION')
|
||||
app.config["FLATPAGES_AUTO_RELOAD"]=env('FLATPAGES_AUTO_RELOAD')
|
||||
app.config["FLATPAGES_ROOT"]=os.path.abspath(env('pages_root'))
|
||||
|
||||
app.logger.setLevel(logging.DEBUG)
|
||||
# Initialize FlatPages Index
|
||||
@@ -47,7 +49,7 @@ flatpages_index.Links.endpoint="intern.post"
|
||||
flatpages_index.Links.image_url=lambda s,x: url_for(s.endpoint,name=x)
|
||||
flatpages_index.Links.thumb_url=lambda s,x: url_for("intern.thumb",size=128,name=x)
|
||||
flatpages_index.Links.image_url=lambda s,x: url_for("intern.post",name=x)
|
||||
flatpages_index.Page.page_defaults={"type":"gallery"}
|
||||
flatpages_index.Page.page_defaults={"type":"gallery", "template":"gallery.html"}
|
||||
flatpages.get('index')
|
||||
|
||||
app.logger.info('Initialize FET Foto Gallery App')
|
||||
@@ -106,17 +108,18 @@ def thumb(size=64,name=''):
|
||||
@page_blueprint.route('/<path:name>/',strict_slashes=False)
|
||||
@page_blueprint.route('/')
|
||||
def post(name=''):
|
||||
print("Post: %s" % name)
|
||||
app.logger.debug("post_name: %s" % name)
|
||||
page = flatpages.get(name)
|
||||
|
||||
if not page is None:
|
||||
page["has_img"]=True
|
||||
page.links.endpoint='intern.post'
|
||||
|
||||
app.logger.debug(dict(page))
|
||||
return render_template(page["template"], post=page,
|
||||
pth=page["dirpath"])
|
||||
|
||||
if os.path.exists(os.path.join(app.config["FLATPAGES_ROOT"],name)):
|
||||
app.logger.debug("sending static:%s" % name)
|
||||
return send_from_directory(app.config["FLATPAGES_ROOT"],name)
|
||||
elif os.path.exists(os.path.join('static',name)):
|
||||
print("send from static dir %s" % name)
|
||||
@@ -126,9 +129,6 @@ def post(name=''):
|
||||
elif os.path.exists(os.path.join("blueimp",name)):
|
||||
return send_from_directory(os.path.abspath('blueimp'),name)
|
||||
else:
|
||||
print("%s not found" % os.path.abspath(os.path.join('static',name)))
|
||||
print("%s not found" % os.path.abspath(os.path.join(cfg["fet_assets"],name)))
|
||||
|
||||
return abort(404)
|
||||
|
||||
@api_blueprint.route('/<path:name>.json',strict_slashes=False)
|
||||
|
||||
Reference in New Issue
Block a user