Coder Social home page Coder Social logo

web-api-with-orm's Introduction

web-api-with-orm

This repo contains code for an example RESTful web API with create, read, update, and delete (CRUD) operations and data persistence. It is scalable and intended to serve as a foundation for developing more complex database interfaces in Python using Object-Relational Mapping.

The sample data models represent fictional people and Covid-19 test results, which have a one-to-many relationship. Each person's Covid status is updated automatically based on their most recent test result.

Technologies:

  • Google App Engine and Google Cloud SQL for cloud deployment
  • Flask web framework
  • PostgreSQL for RDBMS
  • SQLAlchemy for ORM
  • marshmallow for data object serialization
  • Swagger for API design and documentation (OpenAPI Specification)

Database connection:

The app requires a PostgreSQL database connection to run. To set this up, add a file to the base directory called "postgres_uri.txt" containing the URI for the database that you would like to use.

For a local connection, the URI will look something like this:

postgresql://<db_user>:<db_password>@localhost/<db_name>

API security:

The example API requires basic authorization for operations that modify the database. To set this up, add a file to the base directory called "auth.txt" containing credentials to be used for authorization, formatted as a dictionary, e.g.

{"<user_1>": "<password_1>", "<user_2>": "<password_2>"}

NOTE: this authorization method is used for testing purposes only and should not be considered secure for use with a production database.

Using the API:

Once the database URI and authorization credentials are configured, the app can be tested locally by running "main.py". When the app is run, Swagger will automatically build documentation and a browser interface, which can be used to explore and test the API:

web-api-with-orm's People

Contributors

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