Greg Peckory
Greg Peckory

Reputation: 8058

Open static html document using webapp2

I have my folder set up like this:

enter image description here

in my guestbook.py file I have the following code:

import webapp2

LOGIN_HTML = open('login.html').read()
REGISTER_HTML = open('register.html').read()


class LoginPage(webapp2.RequestHandler):
    def get(self):
        self.response.write(LOGIN_HTML)

class RegisterPage(webapp2.RequestHandler):
    def get(self):

        self.response.write(REGISTER_HTML)


app = webapp2.WSGIApplication([
    ('/', LoginPage),
    ('/register.html', RegisterPage),
], debug=True)

This runs the code fine, but won't access css or image files from the folder. Why is this happening? How might I fix this?

EDIT

app.yaml

version: 1
runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /.*
  script: guestbook.app


libraries:
- name: webapp2
  version: latest

login.html

line 7:  <link rel="stylesheet" type="text/css" href="testctyles.css" />

line 16: <img src="imgs/bellogo.png" alt="UniCoreLogo" style="width:45px;height:45px;vertical-align:middle">

testctyle.css

body{
    background-image: url("imgs/greyback.jpg");
}

Upvotes: 0

Views: 891

Answers (1)

erichiggins
erichiggins

Reputation: 596

To provide a proper answer to your question, I would need to see your app.yaml and also the HTML snippets where your login.html and register.html refer to the static resources. It could be that you haven't configured the app to serve the static files, or there is a discrepancy in the paths between the config and your HTML. There's more information at the following links which should help:

Upvotes: 1

Related Questions