Coder Social home page Coder Social logo

pets's Introduction

pets

Intro to Flask

  • install flask
  • create simple app.py
  • show how to run app
  • build some basic routes (with params)
  • add .env file for simplicity (need to install python-dotenv) and .gitignore

SQLAlchemy & Alembic

  • install flask-sqlalchemy
  • set up models.py with Dog class
  • install flask-migrate, setup alembic and SQLAlchemy
    • use a better file template (file_template = %%(year)04d-%%(month)02d-%%(day)02d_%%(hour)02d-%%(minute)02d-%%(second)02d_%%(rev)s_%%(slug)s)
    • add the naming convention
  • run flask db init, flask db migrate, flask db upgrade
  • add dogs and query dogs with flask shell
  • write a seed script
    • can optionally install faker

APIs

  • create a /dogs route
  • add serializer for Dog (install sqlalchemy-serializer)
  • demo POSTman
  • create a /dogs/int:id route
    • test for 404s
  • allow POST to /dogs
  • add DELETE
  • add PATCH

Constraints/Validations

  • Make Dog name required (discuss nullable and unique)
  • Create a custom constraint for age (cannot be neg)
  • Add validation for name and age

Relationships

  • add Owner class
  • add fk to Owner on Dog
  • rewrite seed script
    • tricky talk about when ids get added
  • add relationship
  • add serialize_rules
  • add route for owners

Adding the Front-End

  • create a simple react app with vite
    • run npm create vite@latest
    • run npm react-router-dom
  • set up a fetch
  • add CORS
  • set up form POST (with error handling)

Auth

  • install bcrypt
  • create a User class
    • setup password column with encryption
  • create login/signup/logout routes (don't forget secret key)
  • create check session route
  • use check session in react app

pets's People

Contributors

bencavins 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.