External CSS sheet CSS does not work when working on GAE

I have main.html that references web.css, and when I run the main file, it works fine with CSS, but when I run it all in the Google engine, it does not apply CSS. From GAE magazines I get

INFO 2012-05-10 01:58:46,526 dev_appserver.py:2891] "GET /web.css HTTP/1.1" 404 - INFO 2012-05-10 01:58:46,540 dev_appserver.py:2891] "GET /favicon.ico HTTP/1.1" 200 - 

This is in my html file

 <html> <head> <link rel="stylesheet" type="text/css" href="web.css"/> </head> <body> <h1> Hi </h1> </body> </html> 

And this is my code

 import os import webapp2 import jinja2 import re from datetime import datetime from google.appengine.ext import db from utility_functions import valid_username, valid_password, valid_email class Handler(webapp2.RequestHandler): def render(self, link, values={}): je = jinja2.Environment(autoescape=True, loader=jinja2.FileSystemLoader( os.path.join(os.path.dirname(__file__), 'templates'))) template = je.get_template(link) self.response.out.write(template.render(values)) class MainPage(Handler): def get(self): self.render('main.html') handlers = [('/', MainPage)] app = webapp2.WSGIApplication(handlers, debug=True) 
+4
source share
2 answers

For anyone who stumbles upon this question, static files should be declared using a static file handler . For example, the css directory is used for this, which maps the css directory at the root of your application directory to the public css directory at the root of your appspot domain:

 - url: /css static_dir: css 
+7
source

add this to your app.yaml :

 - url: /web.css static_files: web.css upload: web.css 
+4
source

Source: https://habr.com/ru/post/1411674/


All Articles