Skip to content

Commit

Permalink
More docs added
Browse files Browse the repository at this point in the history
  • Loading branch information
CheeseCake87 committed Oct 31, 2023
1 parent 3790367 commit 71641ac
Show file tree
Hide file tree
Showing 88 changed files with 9,393 additions and 8,044 deletions.
335 changes: 335 additions & 0 deletions docs/blueprint-config-toml.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,335 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>The Flask-Imp Blueprint Config File | Flask-Imp</title>
<link rel="stylesheet" href="static/water.css">
<link rel="stylesheet" href="static/pygments.emacs-dull.css">
<link rel="apple-touch-icon" sizes="180x180" href="static/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="static/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="static/favicon-16x16.png">
<link rel="manifest" href="static/site.webmanifest">
<link rel="mask-icon" href="static/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
</head>
<body>

<aside>
<img width="50%" src="static/Flask-Imp-Medium.png" alt="Flask-Imp Logo" style="margin-top: 20px;">
<h1>Flask-Imp</h1>
<div><small>Last Updated:</small></div>
<div><small>Tue, 31 Oct 2023</small></div>

<h2>Menu</h2>
<ul>
<li><a href="index.html"><strong>Index</strong></a></li>
</ul>
<ul>


<li><strong>CLI Commands</strong></li>


<ul style="padding-top: 5px; padding-left: 10px;">


<li><a href="cli_commands-flask-imp_init.html">flask-imp init</a></li>



<li><a href="cli_commands-flask-imp_blueprint.html">flask-imp blueprint</a></li>


</ul>



<li><strong>Imp</strong></li>


<ul style="padding-top: 5px; padding-left: 10px;">


<li><a href="imp-introduction.html">Introduction</a></li>



<li><a href="imp-x-config-toml.html">x.config.toml</a></li>



<li><a href="imp-load-env-vars.html">Load Env Variables</a></li>


</ul>



<li><strong>Blueprint</strong></li>


<ul style="padding-top: 5px; padding-left: 10px;">


<li><a href="blueprint-introduction.html">Introduction</a></li>



<li><a href="blueprint-config-toml.html">config.toml</a></li>


</ul>



<li><strong>Imp.x</strong></li>


<ul style="padding-top: 5px; padding-left: 10px;">


<li><a href="imp_x-init_app.html">init_app</a></li>



<li><a href="imp_x-init_session.html">init_session</a></li>



<li><a href="imp_x-import_app_resources.html">import_app_resources</a></li>



<li><a href="imp_x-import_blueprint.html">import_blueprint</a></li>



<li><a href="imp_x-import_blueprints.html">import_blueprints</a></li>



<li><a href="imp_x-import_models.html">import_models</a></li>



<li><a href="imp_x-model.html">model</a></li>




</ul>



<li><strong>Blueprint.x</strong></li>


<ul style="padding-top: 5px; padding-left: 10px;">


<li><a href="blueprint_x-init_session.html">init_session</a></li>



<li><a href="blueprint_x-import_resources.html">import_resources</a></li>



<li><a href="blueprint_x-import_nested_blueprint.html">import_nested_blueprint</a></li>



<li><a href="blueprint_x-import_nested_blueprints.html">import_nested_blueprints</a></li>



<li><a href="blueprint_x-import_models.html">import_models</a></li>



<li><a href="blueprint_x-tmpl.html">tmpl</a></li>


</ul>



<li><strong>flask_imp.security</strong></li>


<ul style="padding-top: 5px; padding-left: 10px;">


<li><a href="flask_imp_security-login_check.html">login_check</a></li>



<li><a href="flask_imp_security-permission_check.html">permission_check</a></li>



<li><a href="flask_imp_security-pass_function_check.html">pass_function_check</a></li>



<li><a href="flask_imp_security-api_login_check.html">api_login_check</a></li>



<li><a href="flask_imp_security-include_csrf.html">include_csrf</a></li>


</ul>



<li><strong>flask_imp.auth</strong></li>


<ul style="padding-top: 5px; padding-left: 10px;">


<li><a href="flask_imp_auth-is_email_address_valid.html">is_email_address_valid</a></li>



<li><a href="flask_imp_auth-is_username_valid.html">is_username_valid</a></li>



<li><a href="flask_imp_auth-generate_csrf_token.html">generate_csrf_token</a></li>



<li><a href="flask_imp_auth-generate_private_key.html">generate_private_key</a></li>



<li><a href="flask_imp_auth-generate_email_validator.html">generate_email_validator</a></li>



<li><a href="flask_imp_auth-generate_numeric_validator.html">generate_numeric_validator</a></li>



<li><a href="flask_imp_auth-generate_alphanumeric_validator.html">generate_alphanumeric_validator</a></li>



<li><a href="flask_imp_auth-generate_password.html">generate_password</a></li>



<li><a href="flask_imp_auth-generate_salt.html">generate_salt</a></li>



<li><a href="flask_imp_auth-encrypt_password.html">encrypt_password</a></li>



<li><a href="flask_imp_auth-authenticate_password.html">authenticate_password</a></li>


</ul>


</ul>

<div style="padding-top: 5px; margin-bottom: 20px;"><small>These docs are generated by a
<a href="https://github.com/CheeseCake87/Flask-Imp/tree/master/docs_gen">Flask Static Site Generator</a>
built by <a href="https://github.com/CheeseCake87">David Carmichael</a> hosted on GitHub Pages.</small></div>
</aside>

<section>
<h1 style="font-size: 2.6rem; margin: 0;">The Flask-Imp Blueprint Config File</h1>
<p>The Flask-Imp Blueprint will load configuration from a <code>config.toml</code> file, which is located in the same directory as the
<code>__init__.py</code> file.</p>
<p>File: <code>config.toml</code></p>
<div class="highlight"><pre><span></span><span class="n">enabled</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;yes&quot;</span>

<span class="k">[settings]</span>
<span class="n">url_prefix</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;&quot;</span>
<span class="n">subdomain</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;&quot;</span>
<span class="n">url_defaults</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span>
<span class="n">static_folder</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;&quot;</span>
<span class="n">template_folder</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;&quot;</span>
<span class="n">static_url_path</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;&quot;</span>
<span class="c1">#root_path = &quot;&quot;</span>
<span class="c1">#cli_group = &quot;&quot;</span>

<span class="k">[session]</span>
<span class="n">var</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;&quot;</span>
</pre></div>
<p>This config reflects the args that are passed to a regular Flask Blueprint class, the addition of the ability to
enable/disable the Blueprint, and set session variables.</p>
<p>For more information about the args of a regular Flask Blueprint see:
<a href="https://flask.palletsprojects.com/en/3.0.x/api/#flask.Blueprint">Flask docs (Blueprint)</a></p>
<h4>Example of advance use case for blueprint config files:</h4>
<div class="highlight"><pre><span></span>testing_blueprint/
├── routes/
│ └── index.py
├── static/
│ └── ...
├── templates/
│ └── www/
│ └── index.html
├── __init__.py
├── pro_config.py
└── dev_config.toml
</pre></div>
<div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">app</span> <span class="kn">import</span> <span class="n">app</span>
<span class="kn">from</span> <span class="nn">flask_imp</span> <span class="kn">import</span> <span class="n">Blueprint</span>

<span class="n">bp</span> <span class="o">=</span> <span class="n">Blueprint</span><span class="p">(</span>
<span class="vm">__name__</span><span class="p">,</span>
<span class="n">config_file</span><span class="o">=</span><span class="s2">&quot;dev_config.toml&quot;</span> <span class="k">if</span> <span class="n">app</span><span class="o">.</span><span class="n">config</span><span class="p">[</span><span class="s2">&quot;DEBUG&quot;</span><span class="p">]</span> <span class="k">else</span> <span class="s2">&quot;pro_config.py&quot;</span>
<span class="p">)</span>

<span class="n">bp</span><span class="o">.</span><span class="n">import_resources</span><span class="p">(</span><span class="s2">&quot;routes&quot;</span><span class="p">)</span>


<span class="nd">@bp</span><span class="o">.</span><span class="n">before_app_request</span>
<span class="k">def</span> <span class="nf">before_app_request</span><span class="p">():</span>
<span class="n">bp</span><span class="o">.</span><span class="n">init_session</span><span class="p">()</span>
</pre></div>
<p>File: <code>pro_config.py</code></p>
<div class="highlight"><pre><span></span><span class="n">enabled</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;no&quot;</span>

<span class="k">[settings]</span>
<span class="c1">#url_prefix = &quot;&quot;</span>
<span class="c1">#subdomain = &quot;&quot;</span>
<span class="c1">#url_defaults = { }</span>
<span class="c1">#static_folder = &quot;&quot;</span>
<span class="c1">#template_folder = &quot;&quot;</span>
<span class="c1">#static_url_path = &quot;&quot;</span>
<span class="c1">#root_path = &quot;&quot;</span>
<span class="c1">#cli_group = &quot;&quot;</span>

<span class="k">[session]</span>
<span class="c1">#var = &quot;&quot;</span>
</pre></div>
<p>File: <code>dev_config.py</code></p>
<div class="highlight"><pre><span></span><span class="n">enabled</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;yes&quot;</span>

<span class="k">[settings]</span>
<span class="n">url_prefix</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;/testing&quot;</span>
<span class="c1">#subdomain = &quot;&quot;</span>
<span class="c1">#url_defaults = { }</span>
<span class="n">static_folder</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;static&quot;</span>
<span class="n">template_folder</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;templates&quot;</span>
<span class="c1">#static_url_path = &quot;&quot;</span>
<span class="c1">#root_path = &quot;&quot;</span>
<span class="c1">#cli_group = &quot;&quot;</span>

<span class="k">[session]</span>
<span class="c1">#var = &quot;&quot;</span>
</pre></div>
<p>In the example above, the <code>testing_blueprint</code> will only be enabled if the Flask app is running in debug mode.</p>

</section>

</body>
</html>
Loading

0 comments on commit 71641ac

Please sign in to comment.