stuff
This commit is contained in:
50
flaskapp/__init__.py
Normal file
50
flaskapp/__init__.py
Normal file
@@ -0,0 +1,50 @@
|
||||
# **************************************************
|
||||
# Static / Frozen Website with bootstrap & flaticons
|
||||
# **************************************************
|
||||
import sys
|
||||
from flask import Flask, render_template, send_from_directory,jsonify, redirect
|
||||
#from flask_flatpages import FlatPages, pygments_style_defs
|
||||
from flask_frozen import Freezer
|
||||
from config import Config
|
||||
import os
|
||||
import re
|
||||
from os.path import isfile, abspath
|
||||
import yaml
|
||||
|
||||
package_directory = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
#cfg = Config(file('./config.cfg'))
|
||||
cfg = Config(file(os.path.join(package_directory, '../config.cfg')))
|
||||
|
||||
f=open(os.path.join(package_directory, '../services.yml'),"r")
|
||||
services=yaml.safe_load(f)
|
||||
f.close()
|
||||
|
||||
|
||||
# Loading constants from config file
|
||||
#FLATPAGES_AUTO_RELOAD = cfg.pages_reload
|
||||
#FLATPAGES_EXTENSION = '.md'
|
||||
#FLATPAGES_ROOT = abspath(cfg.pages_root)
|
||||
#FLATPAGES_FP_ROOT = abspath(cfg.pages_root)
|
||||
|
||||
# Initialize application
|
||||
app = Flask(__name__, static_folder= "../static")
|
||||
#flatpages = FlatPages(app)
|
||||
#flatpages.get('index')
|
||||
|
||||
app.config.from_object(__name__)
|
||||
app.config["FREEZER_RELATIVE_URLS"]=True
|
||||
#app.config["FREEZER_DESTINATION"]="/home/andis/www/triton_welcome/build/"
|
||||
app.config["FREEZER_DESTINATION"]="../build"
|
||||
freezer = Freezer(app)
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
return render_template('main.html', title=cfg.title, services=services["services"])
|
||||
@app.route('/reload.html')
|
||||
def reload():
|
||||
f=open(os.path.join(package_directory, '../services.yml'),"r")
|
||||
global services
|
||||
services=yaml.safe_load(f)
|
||||
f.close()
|
||||
return redirect('/')
|
||||
Reference in New Issue
Block a user