Skip to main content

Fast light weight web server

Project description

DustAPI - A Fast, Lightweight Python Web Framework

DustAPI is a lightweight web framework written in Python, designed to be simple, efficient, and easy to use. It provides basic routing and response handling, making it an excellent choice for learning about web frameworks or building small to medium-sized web applications.

dustAPI logo

Features

  • Simple and intuitive routing
  • Searchable symmetric encryption (dust server can search encrypted data without decrypting it)
  • Support for all HTTP methods (GET, POST, PUT, DELETE, etc.)
  • WebSocket support
  • Custom response types (JSON, HTML, etc.)
  • Extensible and lightweight
  • Auto-generate API documentation with Swagger
  • JWT and session management support
  • Asynchronous request handling

Installation

To install DustAPI, use pip:

pip install dustapi

Quick Start

Create a DustAPI project

dustapi createproject myproject
cd myproject

Run the DustAPI server

dustapi runserver --host 0.0.0.0 --port 8000 --template-folder templates --static-folder static --log-file app.log

Example Application

from dustapi.application import Dust, get_request
from dustapi.responses import JsonResponse, Response
import os

app = Dust()

UPLOAD_FOLDER = 'uploads'
os.makedirs(UPLOAD_FOLDER, exist_ok=True)

def save_uploaded_file(file_data, upload_folder):
    filename = file_data['filename']
    filepath = os.path.join(upload_folder, filename)
    with open(filepath, 'wb') as f:
        f.write(file_data['content'])
    return filename

@app.route('/', methods=['GET'])
async def home():
    return app.render_template('index.html', title="Home", heading="Welcome to DustAPI", content="This is the home page.")

@app.route('/hello', methods=['GET'])
async def hello():
    return "Hello, World!"

@app.route('/json', methods=['GET'])
async def json_example():
    return JsonResponse({"message": "This is a JSON response"})

@app.route('/upload', methods=['POST'])
async def upload_file():
    request = get_request()
    if 'file' not in request.form:
        raise ValueError("No file part in the request")
    
    file_data = request.form['file']
    filename = save_uploaded_file(file_data, UPLOAD_FOLDER)
    return f"File {filename} uploaded successfully"

@app.errorhandler(ValueError)
def handle_value_error(exc):
    return Response(str(exc), status=400)

@app.errorhandler(Exception)
def handle_generic_exception(exc):
    return Response("An unexpected error occurred.", status=500)

if __name__ == '__main__':
    app.run(host='localhost', port=5000)

Documentation

For detailed documentation, visit our official documentation site.

Contributing

We welcome contributions! Please see our Contributing Guide for more details.

Roadmap

  • AI/ML model inference and consumption
  • Middleware support
  • Database ORM integration
  • Improved WebSocket support
  • CLI tools for project scaffolding

License

DustAPI is released under the MIT License. See the LICENSE file for details.

Support

If you encounter any issues or have questions, please open an issue on our GitHub repository.

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

dustapi-0.0.7.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

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

dustapi-0.0.7-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file dustapi-0.0.7.tar.gz.

File metadata

  • Download URL: dustapi-0.0.7.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for dustapi-0.0.7.tar.gz
Algorithm Hash digest
SHA256 d471d0f4daaa4ce545042c16fc8a6e683ae4146ffc141ca0c5944fb18e1f795a
MD5 679da00d67da702e93363a1434729eb3
BLAKE2b-256 07657518e18e0916a0aeb167bc66a6d7fcdfb72ddd7b03dbb84ec43f5217028e

See more details on using hashes here.

File details

Details for the file dustapi-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: dustapi-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for dustapi-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 3907552d62d9d6b5ee771b13a1a8f7e1c63d1f727f744fe17bdc7d3ab6fb11d2
MD5 675ec50dbed811e3b6dbe5fb03cb3370
BLAKE2b-256 60658b2befc5c21c6b0c536a3bf6d484f7e8ae2fba1b35f586a51f8c8efd67ee

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