Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8001645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:08:33+00:00 2026-06-04T16:08:33+00:00

I am working on an application, hosted on openshift and built on their bottle.py

  • 0

I am working on an application, hosted on openshift and built on their bottle.py quickstart example (https://github.com/openshift/bottle-openshift-quickstart) but I have had a hard time getting the use of static files correct. I have a local version that works with the server built into bottle but when I transfer what works locally into an openshift application it behaves differently.

in my local main.tpl the following lines are used to indicate which files should be loaded…

<link rel="stylesheet" href="{{ get_url('static', file_name='base.css') }}">
<link rel="stylesheet" href="{{ get_url('static', file_name='skeleton.css') }}">
<link rel="stylesheet" href="{{ get_url('static', file_name='layout.css') }}">

in my local app.py the following code attempts to serve the correct file…

app = default_app()

@route('/')
@view('main.tpl')
def index():
    return {'get_url': app.get_url}

@route('/static/<file_name>', name="static")
def send_static(file_name):
    if file_name[-3:] == 'css':
        return static_file(file_name, root=os.path.join(os.getcwd(), 'static', 'styles'))

The conditional is there because I was trying to figure out a way to keep the /static directory organized without having to write several similar send_static functions, one that had the root location for css files one that had the root location for js files or whatever.

When the code is used in openshift it no longer works, where the local version inserts a ‘/static/styles/base.css’ into the displayed page, the openshift version only inserts ‘/static/base.css’. To get the css files to load I’ve stumbled into the following code.

My main.tpl remains the same…

<link rel="stylesheet" href="{{ get_url('static', file_name='base.css') }}">
<link rel="stylesheet" href="{{ get_url('static', file_name='skeleton.css') }}">
<link rel="stylesheet" href="{{ get_url('static', file_name='layout.css') }}">

But in my openshift app.py I’ve had to explicitly place the sub-directory into the route

application = default_app()

@route('/')
@view('main.tpl')
def index():
    return {'get_url': application.get_url}

@route('/static/styles/<file_name>', name="static")
def send_static(file_name):
    if file_name[-3:] == 'css':
        root_dir = os.path.join(os.getcwd(), 'static', 'styles')
        return static_file(file_name, root=root_dir)

Am I missing something about the openshift server environment that causes the difference? The app is working but I would really like to know a proper way to get css files loaded and displayed.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T16:08:34+00:00Added an answer on June 4, 2026 at 4:08 pm

    i have evaluate your project. your ran into this issue, totally caused by wrong configuration.
    first,reference here resource.
    How to load a javascript or css file into a BottlePy template?

    you will notice,you can set hash to mapping your static folder

    @route('/static/:path#.+#', name='static')
    def static(path):
        return static_file(path, root='static')
    

    another issue, we need explicit set the views path in your openshift env.

       from bottle import TEMPLATE_PATH                                               
    
       import os                                                                      
       views_path = os.environ['APPDIR'] + '/repo/wsgi/views'                         
       TEMPLATE_PATH.insert(0,views_path)                                             
       app = default_app()  
    

    views in template:

    <head>                                                                         
    <script type="text/javascript" src="{{ get_url('static', path='js/main.js') }}" charset="utf-8"></script>                                                
    </head>                                                                        
    <body>                                                                         
    <p>it's works</p>                                                              
    </body>                                                                        
    </html>  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working in C#.Net Application. I had hosted my application in IIS in
I have an ASP.NET application all things are working fine but after some minutes
I have a working application using python and zeromq and I would like to
I am working on splitting out an existing, working application that I currently have
Now that I have a read-only application working, I am working on the insert
My Application was working fine. But as soon as i updated from ADT 16
My Silvrlight 4 application hosted in ASP.NET MVC 2 working fine when used through
I have an ASP.NET 2.0 application that is working fine in our local environment.
I have a functioning Silverlight 4 application (VS2010, SL4, WCF RIA, hosted on my
I am working on application which fetch Performance counter from application hosted on azure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.