Git Product home page Git Product logo

toy-api's Introduction

Toy flask project

Tasks

  1. Create a "Users" table. A user has an ID (primary key), name, age, location
  2. Create a POST method for adding new users to the table
  3. Create a GET method with a query parameter (user id) for retrieving information about a specific user
  4. Create a GET method for retrieving all the users from the database

User model Snapshot (SQLAlchemy)

class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80), nullable=False)
    age = db.Column(db.Integer, nullable=False)
    location = db.Column(db.String(80), nullable=False)
    email = db.Column(db.String(120), unique=True, nullable=False)

User Endpoints

  1. POST api/users: Create a new user
  2. GET api/users?id=1: Get a user by id
  3. GET api/users: Get all users

How to run

  1. Clone the repo
     git clone https://github.com/codelawani/toy-api.git
  2. Create a virtual environment
     cd toy-api
     python3 -m venv venv
     source venv/bin/activate
  3. Install the requirements
     pip install -r requirements.txt
  4. Add env variables to a .env file - DB_USER, DB_PASS, DB_HOST, DB_NAME, DB_PORT
  5. Run db setup script db_setup.sh (make sure you have mysql installed and take a look at the script before running it)
     chmod +x db_setup.sh
     sudo ./db_setup.sh
  6. Run the app
    python -m app.api

toy-api's People

Contributors

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