Git Product home page Git Product logo

python-p4-flask-sqlalchemy-lab's Introduction

Flask-SQLAlchemy Lab

Learning Goals

  • Build and run a Flask application on your computer.
  • Extend a Flask application to meet the unique requirements of different projects.

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 run pytest -x to run your tests. Use these instructions and pytest's error messages to complete your work in the app/ folder.

Instructions begin here:

  • Design a Flask application that displays information from a database created using Flask-SQLAlchemy and Flask-Migrate.
  • flask db init has already been run. You will need to direct your Flask app to a database at app.db, create models, run a migration with flask db revision --autogenerate -m'<your message>' and create the database file with flask db upgrade.
  • Your database should represent a zoo. There should be three tables: animals, zookeepers, and enclosures.
  • The Animal model should contain a name, a species, a zookeeper, and an enclosure.
  • The Zookeeper model should contain a name, a birthday, and a list of animals that they take care of.
  • The Enclosure model should contain an environment (grass, sand, or water), an open_to_visitors boolean, and a list of animals.
  • Your application should contain three views: animal_by_id, zookeeper_by_id, and enclosure_by_id. Their routes should be animal/<int:id>, zookeeper/<int:id>, and enclosure/<int:id>, respectively.
  • Each view should display all attributes as line items (ul). If there is a one-to-many relationship, each of the many should have its own line item.
  • A seed script, app/seed.py, has been provided to generate test data once your models have been built and migrated to a database. Make sure to run this so that there are resources for the test suite to visit.

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

Examples

Animal View

animal ID 1, name Logan, species Snake, zookeeper Dylan Taylor, enclosure trees

Zookeeper View

zookeeper name Stephanie Contreras, birthday 1996-9-20, 6 animals

Enclosure View

enclosure with pond environment, not open to visitors, 8 animals


Resources

python-p4-flask-sqlalchemy-lab's People

Contributors

ddeleon267 avatar professor-ben avatar

Watchers

 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.