Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

205
Views
Python Flask blueprint without static folder for css and javascript

I have searched similar answer to this and found to no avail.

Using CGI Handler Apache server with an index.cgi

I have to adhere the strict policy on the directory list; they're adamantly refused to have a static folder in the directory for Flask.

I kinda wish Flask add static_js and static_css that would make our life easier.

How do I override the static folder?

It works with a single path for either css or javascript:

# in app.py
app.register_blueprint(index_bp)
app.add_url_rule('/css/<path:filename>', endpoint='css', view_func=app.send_static_file)

app.add_url_rule('/js/<path:filename>', endpoint='js', view_func=app.send_static_file)
# css_dir = /parent_folder/css and read from json load
from config import css_dir

index = Blueprint('index', __name__, template_folder=html_dir, static_folder=css_dir)

# in html file
<link rel='stylesheet' href="{{ url_for('css', filename='bootstrap.min.css') }}">

# note: javascript won't load at all

or

# js_dir = /parent_folder/js and read from json load
from config import js_dir

index = Blueprint('index', __name__, template_folder=html_dir, static_folder=css_dir)

# in the html file
<script type ="text/javascript" src="{{ url_for('js', filename='lib/bootstrap.min.js') }}"></script>

# note: css won't load at all

but does not work:

# multi_dir = /parent_folder and read from json load
from config import multi_dir

index = Blueprint('index', __name__, template_folder=html_dir, static_folder=multi_dir)

# in html file
<link rel='stylesheet' href="{{ url_for('css', filename='bootstrap.min.css') }}">

<script type ="text/javascript" src="{{ url_for('js', filename='lib/bootstrap.min.js') }}"></script>

# note: both won't load at all

I want to include javascript and css folders without a static folder

  1. parent_folder
    • cgi-bin
      • python/perl stuff
    • templates
      • html stuff
    • css
      • css stuff
    • js
      • lib
        • javascript stuff

How do I achieve this?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I figured it out, it can be achieved by create a two python files and register them in the app.py blueprint.

Since Stack Overflow won't let me post code in here due to error which is in correct format.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!