Code Monkey home page Code Monkey logo

tseu_sandbox's Introduction

TSEU FastAPI Sandbox

FastAPI Sandbox for testing App Ideas


Resources

  • Generating a random hex string for seeding purposes
    • $ # Use OpenSSL to generate a random 32-bit sting
      $ openssl rand -hex 32

Setting Up

  • Create a main.py file and make sure that FastAPI works
    • $ # Launch FastAPI manually this time
      $ python -m uvicorn main:app --host 0.0.0.0 --port 8000 --workers 1 --reload
  • With the initial route up and going, perform the initial commit, bring down the container and add a command stanza to docker-compose.yml
    • version: '3.8' 
      
      services: 
        # FastAPI
        api:
          container_name: tseu-sandbox
          image: tseu-sandbox:base 
          build: 
            context: ./sandbox-container 
            # Bring up the Python base image 
            # target: base 
            # Bring up the Python Dev image layer
            target: dev 
          volumes:
            - ./sandbox-container/tseu_sandbox:/usr/src
          ports:
            - 8000:8000
          networks: 
            - tseu-sandbox-app 
          command: bash -c "python -m uvicorn main:app --host 0.0.0.0 --port 8000 --workers 1 --reload"
      
      networks:
        tseu-sandbox-app:
          driver: bridge
  • Base app structure
    • .
      ├── LICENSE
      ├── README.md
      └── app
          ├── __init__.py
          ├── main.py
          └── util
              ├── __init__.py
              └── settings.py
      
      2 directories, 6 files
      • In app.util.settings, work ahead and add settings for the database connections that will be set up next.

Database Support

  • Refactor the app and start adding database support
    • Add a new directory as a home for the database support
    • Add app.db.database to handle database connection activities
    • Add a new directory for the database models which are reflected from the existing MySQL database.
    • Add a loader to centralize access to the models.connections
  • Current app structure:
    • .
      ├── LICENSE
      ├── README.md
      └── app
          ├── __init__.py
          ├── db
          │   ├── __init__.py
          │   ├── database.py
          │   ├── model_loader.py
          │   └── models
          │       ├── __init__py
          │       ├── cope_contributions.py
          │       ├── dues.py
          │       ├── dues_and_cope_track_2yrs.py
          │       ├── mast_agency.py
          │       ├── mast_city.py
          │       ├── mast_county.py
          │       ├── mast_location.py
          │       ├── mast_organizer.py
          │       └── members.py
          ├── main.py
          └── util
              ├── __init__.py
              └── settings.py
      
      4 directories, 19 files

Search Member Routes

  • Create an API route that will return a member by supplying a Social Security Number
    • Add a CRUD definition to query the Member database for member info by SSNo
    • Add a GET route that will return Member info
    • Add a Pydantic schema that will validate the return data for documentation.

tseu_sandbox's People

Contributors

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