update for new flask

This commit is contained in:
2021-11-17 20:07:56 +00:00
parent fd338658a3
commit a98af6e6bb
6 changed files with 7 additions and 50 deletions

View File

@@ -8,14 +8,15 @@ from flask import Flask, Blueprint,render_template, send_from_directory,jsonify,
from flatpages_index import FlatPagesIndex from flatpages_index import FlatPagesIndex
import flatpages_index import flatpages_index
from flask_frozen import Freezer
from config import Config from config import Config
from envs import env
import os import os
# This is the directory, required for absolute file paths # This is the directory, required for absolute file paths
package_directory = os.path.dirname(os.path.abspath(__file__)) package_directory = os.path.dirname(os.path.abspath(__file__))
# Loading the config file # Loading the config file
cfg = Config((os.path.join(package_directory, '../config.cfg'))) cfg = Config((os.path.join(package_directory, 'config.cfg')))
# Loading constants from config file # Loading constants from config file
FLATPAGES_AUTO_RELOAD = cfg.get("FLATPAGES_AUTO_RELOAD",True) # Default can be overwritten by config cfg FLATPAGES_AUTO_RELOAD = cfg.get("FLATPAGES_AUTO_RELOAD",True) # Default can be overwritten by config cfg
@@ -38,13 +39,13 @@ flatpages_index.Links.thumb_url=(lambda s,x: url_for('stuff.thumb', size=128,nam
flatpages.get('index') flatpages.get('index')
app.logger.info('Initialize SimpleSample App') app.logger.info('Initialize Doc App')
app.logger.info('flatpages loaded %d pages' % len(flatpages._pages)) app.logger.info('flatpages loaded %d pages' % len(flatpages._pages))
app.logger.info("Data directory is: %s" % flatpages.root) app.logger.info("Data directory is: %s" % flatpages.root)
app.logger.info("Url prefix;: %s" % cfg.url_prefix) app.logger.info("Url prefix;: %s" % cfg.url_prefix)
app.logger.info("Extensions: %s" % FLATPAGES_EXTENSION) app.logger.info("Extensions: %s" % FLATPAGES_EXTENSION)
freezer = Freezer(app)
page_blueprint = Blueprint('stuff', __name__) page_blueprint = Blueprint('stuff', __name__)
@@ -57,7 +58,7 @@ def thumb(size=64,name=''):
def page(name='index'): def page(name='index'):
page = flatpages.get(name) page = flatpages.get(name)
if not page is None: if page:
page["has_img"]=True page["has_img"]=True
page.links.endpoint='stuff.page' page.links.endpoint='stuff.page'
return render_template(page["template"], post=page, return render_template(page["template"], post=page,

View File

@@ -1,6 +0,0 @@
pages_root: 'data_sample'
static_root: 'static'
default_template: 'page.html'
url_prefix: "/stuff"
FLATPAGES_EXTENSION: ".md"
FLATPAGES_AUTO_RELOAD: True

View File

@@ -3,4 +3,4 @@ Frozen-Flask
config config
gevent gevent
https://github.com/andreassteph/flatpages_index/archive/master.zip https://github.com/andreassteph/flatpages_index/archive/master.zip
envs

9
run.py
View File

@@ -1,9 +0,0 @@
from simple_sample import app,freezer
import sys
if __name__ == "__main__":
if len(sys.argv) > 1 and sys.argv[1] == "build":
freezer.freeze()
else:
app.run(host='0.0.0.0',port=4444, debug=True)

View File

@@ -1,16 +0,0 @@
server {
listen 80 default_server;
listen [::]:80 ;
index index.html index.htm index.nginx-debian.html;
server_name _;
root /var/www/html;
location / {
include uwsgi_params;
uwsgi_pass unix:///srv/simple_sample_flat_index/uwsgi.sock;
}
}

View File

@@ -1,13 +0,0 @@
[Unit]
Description=uWSGI Simple Sample for Flat Page with Index Default
After=network.target
[Service]
#User=www-data
#Group=www-data
WorkingDirectory=/srv/simple_sample_flat_index
Environment="PATH=/srv/simple_sample_flat_index/.env/bin"
ExecStart=/srv/simple_sample_flat_index/.env/bin/uwsgi --ini uwsgi.ini
[Install]
WantedBy=multi-user.target