GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - BaseMax/SimpleFastPyAPI: This is a simple REST API built with Python and FastAPI and SQLAlchemy for CRUD operations (Create, Read, Update, Delete) on users. FastAPI is a powerful web framework for building APIs.

BranchesTags
Open more actions menu

Latest commit

 

History

111 Commits
111 Commits

Folders and files

NameName
Last commit message
Last commit date
app
app
 
 
.env.example
.env.example
 
 
.gitignore
.gitignore
 
 
Dockerfile
Dockerfile
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
main.py
main.py
 
 
requirements.txt
requirements.txt
 
 
users.db
users.db
 
 

Repository files navigation

Simple FastAPI Py

My Awesome FastAPI Project

This is a simple REST API built with Python and FastAPI and SQLAlchemy for CRUD operations (Create, Read, Update, Delete) on users. FastAPI is a powerful web framework for building APIs.

Installation

Clone this repository to your local machine:

git clone https://github.com/BaseMax/SimpleFastPyAPI

Change into the project directory:

cd SimpleFastPyAPI

Build Docker:

docker build -t SimpleFastPyAPI .

Run the application:

docker run -p 8000:8000 -v $(pwd)/users.db:/app/users.db SimpleFastPyAPI

Install the project dependencies:

pip install -r requirements.txt

Run the application directly without Docker:

uvicorn main:app --reload

The application will start and be available at http://localhost:8000.

API Endpoints

Retrieve a list of users:

GET /users

Returns a list of all users in the system:

curl http://localhost:8000/users/ -H "Accept: application/json"

Response:

[
    {
        "email": "[email protected]",
        "id": 1,
        "password": "password1",
        "name": "Alice"
    },
    {
        "email": "[email protected]",
        "id": 2,
        "password": "password2",
        "name": "Bob"
    },
    {
        "email": "[email protected]",
        "id": 3,
        "password": "password3",
        "name": "Charlie"
    }
]

Retrieve details for a specific user:

GET /users/{user_id}

Returns details for a specific user with the given user_id:

curl http://localhost:8000/users/1 -H "Accept: application/json"

Response:

{
    "email": "[email protected]",
    "id": 1,
    "password": "password1",
    "name": "Alice"
}

Add a new user

POST /users

Adds a new user to the system. The request body should include a JSON object with the following properties:

  • name (string, required): the name of the user
  • email (string, required): the email address of the user
  • password (string, required): the password for the user
curl -X POST http://localhost:8000/users/
   -H 'Content-Type: application/json'
   -d '{"name":"Ali","password":"123456", "email": "[email protected]"}'

Response:

{
    "email": "[email protected]",
    "password": "123456", 
    "id": 4, 
    "name": "Ali"
}

Update an existing user

PUT /users/{user_id}

Updates an existing user with the given user_id. The request body should include a JSON object with the following properties:

  • name (string): the new name for the user
  • email (string): the new email address for the user
curl -X PUT http://localhost:8000/users/1
     -H "Accept: application/json"
     -d '{"name": "Reza", "email": "[email protected]"}'

Response:

{"message": "User updated successfully"}

Delete a user

DELETE /users/{user_id}

Deletes the user with the given user_id:

curl -X DELETE http://localhost:8000/2

Response:

{"message": "User deleted successfully"}

License

This project is licensed under the GPL-3.0 License - see the LICENSE file for details.

Copyright 2023, Max Base

About

This is a simple REST API built with Python and FastAPI and SQLAlchemy for CRUD operations (Create, Read, Update, Delete) on users. FastAPI is a powerful web framework for building APIs.

Topics

apiapi-restfulfastapifastapi-crudfastapi-examplefastapi-pyfastapi-pythonfastapi-samplefastapi-userfastapi-userspypythonpython-fastapipython3restfulrestful-apisqlalchemy

Resources

Readme
GPL-3.0 license
Activity

Stars

40 stars

Watchers

3 watching

Forks

39 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.