mardi 1 décembre 2020

Flask, Jinja2, links to HTML files that aren't templates

I have a lot of HTML files that I'd like to include on my application and link to. I don't want to specify hundreds of routes manually to do this. I am trying to figure out exactly how to serve up these HTML files in flask without explicitly specifying routes for them. How can I tell Flask to let me serve up raw HTML files?

Let me clarify, because I'm sure this is confusing as is. First, here's the basic file structure.

├── categories
│   ├── Data-Science
│   │   ├── Basics.html
│   │   ├── Basics.md
│   │   ├── Bayesian.html
│   │   ├── Bayesian.md
│   │   ├── Combinatorics.html
│   │   ├── Combinatorics.md
│   │   ├── NumericalVsCategorical.html
│   │   ├── NumericalVsCategorical.md
│   │   ├── Preprocessing.html
│   │   ├── Preprocessing.md
│   │   ├── Probability-Basics.html
│   │   ├── Probability-Basics.md
│   │   ├── Probability-Sets.html
│   │   ├── Probability-Sets.md
│   │   ├── PyMC3.html
│   │   ├── PyMC3.md
│   │   ├── TensorFlow.html
│   │   ├── TensorFlow.md
│   │   └── assets
│   │       ├── BayesianPosterior.png
│   │       ├── BayesianPosteriorBugGraph.png
│   │       ├── Screen\ Shot\ 2020-11-28\ at\ 7.46.54\ PM.png
│   │       └── lambda-property.png
├── categories.py
├── front_matter.py
├── main.py
├── static
│   ├── assets
│   │   └── media
│   │       ├── Lists-Random.png
│   │       ├── Logo.png
│   │       ├── Python-RegEx-2.png
│   │       ├── Python-RegEx.png
│   │       ├── Screen\ Shot\ 2020-11-30\ at\ 11.13.24\ AM\ (2).png
│   │       ├── Screen\ Shot\ 2020-11-30\ at\ 11.13.24\ AM.png
│   │       ├── Stat
│   │       │   ├── Associativity.png
│   │       │   ├── BayesianPosterior.png
│   │       │   ├── BayesianPosteriorBugGraph.png
│   │       │   ├── IndicatorFunction.png
│   │       │   ├── IndicatorFunctionProperties.png
│   │       │   ├── lambda-for-continuous.png
│   │       │   └── lambda-property.png
│   │       ├── linear-algebra-homepage.png
│   │       ├── navbar.html
│   │       ├── python-homepage-1.png
│   │       ├── python-homepage-2.png
│   │       └── stat-homepage-violin-plots.png
│   ├── scripts
│   │   └── main.js
│   └── styles
│       ├── prism.css
│       ├── prism.js
│       ├── style.css
│       ├── style.css.map
│       ├── style.min.css
│       └── style.scss
├── templates
│   ├── category-indices
│   │   ├── data-science.html
│   │   ├── machine-learning.html
│   │   └── python.html
│   ├── category-layout.html
│   ├── home.html
│   ├── layout.html
│   ├── navbar.html
│   └── notes.html
├── test.md
└── test_app.py

I get that's a bit exhaustive. But, here's what's important from it: The Data Science directory. That has the .html files that I want to use. I suppose I could just go ahead and make routes to each one, but I have other .html files too. I just want to be able to use an a link or something similar to link to these pages, but Flask won't let me. What can I do to solve this issue?

I am probably forgetting some information you may need to help me. Please just ask, and I'll provide as much more as I can. Thanks!




Aucun commentaire:

Enregistrer un commentaire