Beispiel #1
0
    def _init_core(self, root_path, config_file):
        self.root_path = root_path

        self._tmpdir = tempfile.mkdtemp()
        os.mkdir(os.path.join(self._tmpdir, "templates"))
        os.mkdir(os.path.join(self._tmpdir, "static"))

        self.config.load_toml(config_file)

        self.freezer = flask_frozen.Freezer(self)

        self.assets = AssetEnvironment(self)

        self.jinja_env.loader = RimeLoader(self)
        self.jinja_env.globals['string_as_template'] = self._string_as_template

        @self.route("/static/<path:filename>")
        def static(filename):
            """
            Handle layered static files
            """
            if not filename: flask.abort(404)
            for static_dir in self.static_dirs:
                file_path = os.path.join(static_dir, filename)
                if os.path.isfile(file_path):
                    return flask.send_from_directory(static_dir, filename)
            flask.abort(404)
Beispiel #2
0
def main():
    app.config['SERVER_NAME'] = 'junior.guru'
    app.config['FREEZER_DESTINATION'] = Path(app.root_path) / '..' / '..' / 'public'
    app.config['FREEZER_BASE_URL'] = 'https://junior.guru'
    app.config['FREEZER_STATIC_IGNORE'] = ['src']
    app.config['FREEZER_DESTINATION_IGNORE'] = ['now.json']

    warnings.filterwarnings('error', category=flask_frozen.FrozenFlaskWarning)

    freezer = flask_frozen.Freezer(app)
    freezer.freeze()
Beispiel #3
0
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
"""Freeze the Who Goes First web app."""

import flask_frozen

from whogoesfirst import app

freezer = flask_frozen.Freezer(app)

app.config['FREEZER_DESTINATION'] = './public'
app.config['FREEZER_REDIRECT_POLICY'] = 'error'

if __name__ == '__main__':
    freezer.freeze()
Beispiel #4
0
def main():

    app = application.get_app()
    freezer = flask_frozen.Freezer(app)

    freezer.freeze()
Beispiel #5
0
import flask, flask_frozen
from flask import request, jsonify

app = flask.Flask(__name__)
app.config["DEBUG"] = True


@app.route("/api/v1", methods=['GET'])
def home():
    return jsonify({"name": "jay3332 API", "endpoints": ["/test"]})


@app.route("/api/v1/test", methods=['GET'])
def test():
    return jsonify({"message": "Test"})


if __name__ == '__main__':
    flask_frozen.Freezer(app).freeze()