Giter VIP home page Giter VIP logo

cssi-7.4-static-files-in-app-engine's Introduction

#Serving Static Files

##Challenge - Add Styling to your HelloWorld App

  • Create a new file called style.css.
  • Add some simple styling in the style.css file (font color, an image border, background color)
  • Link the style.css sheet to helloworld.html
  • View your styled page on localhost:8080
  • Show us when you’re done.

[The solution is below, only cheaters would scroll down to look!]

gif of a cheating runner

Lesson Notes

Unlike other environments, merely linking the CSS file by using <link rel="stylesheet" type="text/css" href="style.css"> doesn't quite work.

GAE doesn't know where to look for our style.css file unless we configure it in the app.yaml file. Our stylesheet is an example of a static file. Images, JavaScript code, video, and Flash animations are also examples of static files that we need to tell AppEngine how to access.

Configuring app.yaml for Static Files

  • Static files need to be kept in their own directory.
  • In app.yaml, add a handler that routes to that directory and declare that directory as static using static_dir
handlers:
- url: /img
  static_dir: img

- url: /.*
  script: main.app

In this example, a directory name "img" contains all of our locally stored image files.

##STUDENT PROJECT: UPLOADING PROFILE PAGE TO GAE

Move your profile page HTML and CSS files into the webapp2 framework. Doing this will allow you to add some additional features (like custom user messages, blog posts and comments) to your already awesome profile page.

You will need to remember

  • The webapp2 framework
  • template.render()
  • static_dir
  • Optionally use self.request.get() to pass in a template variable and have your page respond.

View Serving Static Files on Learn.co and start learning to code for free.

cssi-7.4-static-files-in-app-engine's People

Contributors

fislabstest avatar nanselmo avatar sarogers avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.