Level 1 web application Python
当前位置:以往案例 > >Level 1 web application Python
2018-10-06

Level 1



For this level you must write a simple web application that generates two pages. You are
given a set of requirements below, these are encoded in a set of tests (level1_functional.py
in the
starter kit) that your application must pass. The tests correspond to the
functional requirements below.




Functional requirements


Welcome to Jobs
As a visitor to the site, when I load the home page I see the title text "Welcome to Jobs".

About Page Link
As a visitor to the site, when I load the home page I see a link to another page
with the link text "About".

About Page
As a visitor to the site, when I click on the link "About" I am taken to
a page that contains the site manifesto, including the words "Jobs is a new, exciting, job posting service like nothing you've seen before!".

Consistent Design
As a visitor to the site, I notice that all the pages on the site have the same
design with the same colours and fonts used throughout.



Each page will have a similar structure and will link to a
common CSS stylesheet.


Unit Tests



There are no unit tests for this level.


Your Task

To achieve these requirements you will need to build a bottle web application that
is able to serve the two HTML pages (Home and About) and the associated
stylesheet.  The techniques to do this are covered here:




Python Web Applications.

Generating HTML Pages looks at
the Bottle page templating system.

Testing Python Programs covers
running unit tests.


Getting Started



You should be able to unpack the starter kit and runmain.pyto see a very simple
single page web application that is the starting point for your work.   You need to extend this
to meet the requirements above.   This application is very similar to others that you will
have written in tutorials and so should not present any new problems for you to solve; you
just need to apply the techniques you've already learned.




The functional requirements have been laid out in a suggested ordering. Start by writing
code to meet the first requirement before moving on to the second.  Treat each requirement
as a sub-problem. Understand what is asked of you and design a solution, then implement it.
These requirements may seem too trivial to work like this but as they get more complicated
you will benefit from this approach.




Run the functional tests before and after you implement each requirement. You should see
the test fail before, and when you see it pass you know you have a correct solution.  This is
known as Test Driven Development – normally you would write the tests yourself to
encode your understanding of the users requirements.


在线提交订单