Code Monkey home page Code Monkey logo

fastapi's Introduction

FastApi

This is a fastapi application backed by Postgresql database.

This application stored the posts created by multiple users and the votes/likes they have given to each of the posts.

The api in response provides a detailed information about the post contents, the owner/user who created the post and the votes/likes it has been given.

Installation

Please follow the steps to run the application successfully.

  1. Clone the repository using the below command.
git clone https://github.com/Anu1996rag/fastapi.git
  1. Create a virtual environment
python3 -m venv <virtual_environment_name>
  1. Activate the virtual environment
source /<virtual_environment_name>/bin/activate
  1. Use the package manager pip to install the requirements.
pip install -r requirements.txt
  1. Run the server using the below command.
uvicorn app.main:app
  1. Make sure the postgresql service is installed in your system and it is running by running the following command.
sudo /etc/init.d/postgresql status
  1. To start it you can issue the command
sudo /etc/init.d/postgresql start
  1. To stop you can issue the command
sudo /etc/init.d/postgresql-8.3 stop
  1. If you are using poetry, follow the below set of commands.
poetry shell
poetry install
poetry run uvicorn app.main:app
  1. You should see the below response
INFO     2022-11-16 11:30:28.782 | uvicorn.server:serve | Started server process [17055]
INFO     2022-11-16 11:30:28.783 | uvicorn.lifespan.on:startup | Waiting for application startup.
INFO     2022-11-16 11:30:28.783 | uvicorn.lifespan.on:startup | Application startup complete.
INFO     2022-11-16 11:30:28.784 | uvicorn.server:_log_started_message | Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)

Run Tests

Use below command to run the tests

pytest -v

API Docs

To access the API documentation, use the URL http://127.0.0.1:8000/docs#

image

Using Docker

You can also pull the docker image using the below command.

Make sure you have the docker installed in your system.

docker pull anurag1996/fastapi-postgres

Check logs for the api using below command

docker logs <container_id> --tail N

fastapi's People

Contributors

anurag14041996 avatar anu1996rag avatar

Stargazers

Samuel Katapur avatar

Watchers

Samuel Katapur avatar  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.