Skip to main content

A basic Quick API Setup using Flask, intended for rapid project initiation.

Project description

QUAS (Quick API Setup) with Flask

Description

A basic Quick API Setup using Flask, intended for rapid project initiation.

This project is intended to be a starting point for future projects. It includes a structured organization of routes, controllers, models, and utility functions to save development time.

Prerequisites

  • Python 3.12+
  • Virtualenv (optional but recommended)
  • PostgreSQL (or any other database you prefer)

Setup

  1. Clone the repository

  2. Create and activate a virtual environment:

    cd project
    python3 -m venv venv
    source venv/bin/activate  # On Windows use `venv\Scripts\activate`
    
  3. Install dependencies:

    pip install -r requirements.txt
    
  4. Set up environment variables: Create a .env file in the root directory and add the necessary environment variables:

    FLASK_APP=run.py
    FLASK_ENV=development
    DATABASE_URL=<your_database_url>
    
  5. Run the application:

    flask run
    

Implementing Tests

Install PyTest

Add PyTest to your requirements.txt:

pytest
pytest-flask

Test Directory Structure

tests/
├── test_models.py
├── test_routes.py
└── test_utils.py

Example Tests

  1. test_models.py:
import pytest
from app.models.user import AppUser

def test_user_creation():
    user = AppUser(username="testuser", email="test@example.com")
    assert user.username == "testuser"
    assert user.email == "test@example.com"
  1. test_routes.py:
import pytest
from app import create_app

@pytest.fixture
def client():
    app = create_app()
    app.config['TESTING'] = True
    with app.test_client() as client:
        yield client

def test_home_route(client):
    rv = client.get('/')
    assert rv.status_code == 200
    assert b"Welcome" in rv.data

Additional Steps

  1. Configure Testing Environment:

    • Ensure your create_app function in init.py is configured to handle testing.
  2. Run Tests:

    • Use pytest to run your tests:
    pytest
    

By adding these tests and documentation, you'll make your project more robust and easier to maintain, helping you save even more time in the long run.


Contributing

Feel free to submit issues, fork the repository, and send pull requests!

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

create_quas_app-0.5.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

create_quas_app-0.5-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file create_quas_app-0.5.tar.gz.

File metadata

  • Download URL: create_quas_app-0.5.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for create_quas_app-0.5.tar.gz
Algorithm Hash digest
SHA256 f75fc7c6f081e8e6a15ebcdb45978c887cfd32b7cb79250a837b948c94389100
MD5 4bf32e6f0cd821bf3c6f19e2462c9c42
BLAKE2b-256 774c6a0bdb77d39739b9f833f4b90ae99d9f534f774d96373f77c5fdb5d73490

See more details on using hashes here.

File details

Details for the file create_quas_app-0.5-py3-none-any.whl.

File metadata

  • Download URL: create_quas_app-0.5-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for create_quas_app-0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 ce62237ffd0742bf2ec775d013f7452a88c7c7ebbe8d0937e341473ab3a78d62
MD5 7e39acc79ef9bb5daf5b63fbd1e65bb8
BLAKE2b-256 b945e97be944daccd89bc267e70696feab815d60fb49a52a3cc312dc5ee00ab0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page