Giter Club home page Giter Club logo

python-p4-routing-and-views-lab's Introduction

Flask Routing and Views Lab

Learning Goals

  • Build and run a Flask application on your computer.
  • Manipulate and test the structure of a request object.

Key Vocab

  • Web Framework: software that is designed to support the development of web applications. Web frameworks provide built-in tools for generating web servers, turning Python objects into HTML, and more.
  • Extension: a package or module that adds functionality to a Flask application that it does not have by default.
  • Request: an attempt by one machine to contact another over the internet.
  • Client: an application or machine that accesses services being provided by a server through the internet.
  • Web Server: a combination of software and hardware that uses Hypertext Transfer Protocol (HTTP) and other protocols to respond to requests made over the internet.
  • Web Server Gateway Interface (WSGI): an interface between web servers and applications.
  • Template Engine: software that takes in strings with tokenized values, replacing the tokens with their values as output in a web browser.

Instructions

This is a test-driven lab. Run pipenv install to create your virtual environment and pipenv shell to enter the virtual environment. Then enter the server/ directory and run pytest -x to run your tests. Use these instructions and pytest's error messages to complete your work in the server/ directory. If you prefer working in a Flask environment to running your application as a script, remember to configure it with the following commands from the server/ directory:

$ export FLASK_APP=app.py
$ export FLASK_RUN_PORT=5555

Instructions begin here:

  • Design a Flask application that carries out basic Python functions using routing and views.
  • Your index() view should be routed to at the base URL with /. It should Contain an h1 element that contains the title of this application, "Python Operations with Flask Routing and Views".
  • A print_string view should take one parameter, a string. It should print the string in the console and display it in the web browser. Its URL should be of the format /print/parameter.
  • A count() view should take one parameter, an integer. It should display all numbers in the range of that parameter on separate lines. Its URL should be of the format /count/parameter.
  • A math() view should take three parameters: num1, operation, and num2. It must perform the appropriate operation on the two numbers in the order that they are presented. The included operations should be: +, -, *, div (/ would change the URL path), and %. Its URL should be of the format /math/<num1>/<operation>/<num2>.

Once all of your tests are passing, commit and push your work using git to submit.


Resources

python-p4-routing-and-views-lab's People

Contributors

jlboba avatar linda-seiter avatar lizbur10 avatar pgill97 avatar professor-ben avatar

Stargazers

 avatar  avatar  avatar

Watchers

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

python-p4-routing-and-views-lab's Issues

\n not actually working with Flask

Canvas Link

https://learning.flatironschool.com/courses/6201/assignments/234459?module_item_id=549423

Concern

The test for count() gives us an AssertionError unless we use a for loop and add \n to the end of each iteration, but Flask is still displaying everything on a single line when \n is used.
I had to look it up, but using
instead of \n does place each element on a new line, though it won't pass the test.

Additional Context

No response

Suggested Changes

Either explain why we would use newline with \n despite it not actually working when we go to the route, or use
in the test.

math() not working as described

Canvas Link

https://learning.flatironschool.com/courses/6201/assignments/234459?module_item_id=549423

Concern

The instructions tell us that:

Its URL should be of the format /math/<num1><operation><num2>.

It isn't possible for this to work, since anything we enter after "/math/" will be read as only a single input. It will need to be

/math/<num1>/<operation>/<num2>

Since we've just started this phase and have very little idea of why that is the case, it makes it really difficult to understand why the tests aren't passing and why we're getting errors.

Additional Context

No response

Suggested Changes

Correct it to say that the URL should be of the format /math/<num1>/<operation>/<num2>

Formatting error

Canvas Link

https://learning.flatironschool.com/courses/6209/assignments/234544?module_item_id=549606

Concern

One of the view functions has an incorrect instruction. Here is the original instruction:

"A math() view should take three parameters: num1, operation, and num2. It must perform the appropriate operation on the two numbers in the order that they are presented. The included operations should be: +, -, *, div (/ would change the URL path), and %. Its URL should be of the format /math/num1 operation num2"

Additional Context

No response

Suggested Changes

URL formatting is incorrect based on the tests provided. It should instead be:

/math/num1/operation/num>

The backslashes are missing.

Requested Formatting Difference Between Tests and Deliverables

Canvas Link

https://learning.flatironschool.com/courses/6560/assignments/243002?module_item_id=571674

Concern

In display of the README at the link, it is not correctly displaying the requested format in the markdown version of itself. In the raw README on line 62 and in the tests at lines 48-51 it's asking for the route to include slashes between the parameters. The site itself is displaying that incorrectly.

Additional Context

No response

Suggested Changes

No response

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.