Skip to main content

A Python web framework

Project description

BlazeNet

BlazeNet is a Python web framework inspired by Flask. It provides a simple and lightweight solution for building web applications.

Features

  • Routing: Define routes and associate them with view functions.
  • Templating: Render HTML templates using Jinja2.
  • Database Integration: Integrate SQLAlchemy for database operations.
  • Easy to Use: Simple and intuitive API for developing web applications.

Installation

You can install BlazeNet using pip:

pip install blaze-net

Or clone this repository to your local machine:

git clone https://github.com/Alan69/blaze_net.git

Usage

from blaze_net import BlazeNet
from model import User

app = BlazeNet()

@app.route('/')
def index(request):
    return 'Hello, BlazeNet!'

@app.route('/json-reponce/')
def json_reponce(request):
    # Create a session
    session = app.Session()

    # Query all users from the database
    users = session.query(User).all()
    user_dicts = []
    for user in users:
        user_dict = {
            'id': user.id,
            'username': user.username,
            'email': user.email
        }
        user_dicts.append(user_dict)
    # Close the session
    session.close()
    return app.json_response(user_dicts)

if __name__ == "__main__":
    app.run()

Model

from typing import List
from typing import Optional
from sqlalchemy import ForeignKey
from sqlalchemy import String
from sqlalchemy.orm import DeclarativeBase
from sqlalchemy.orm import Mapped
from sqlalchemy.orm import mapped_column
from sqlalchemy.orm import relationship
from blaze_net import BlazeNet

app = BlazeNet()

class Base(DeclarativeBase):
    pass

class User(Base):
    __tablename__ = "user_account"
    id: Mapped[int] = mapped_column(primary_key=True)
    username: Mapped[str] = mapped_column(String(30))
    email: Mapped[Optional[str]]
    addresses: Mapped[List["Address"]] = relationship(
        back_populates="user", cascade="all, delete-orphan"
    )
    def __repr__(self) -> str:
        return f"User(id={self.id!r}, name={self.name!r}, fullname={self.fullname!r})"

class Address(Base):
    __tablename__ = "address"
    id: Mapped[int] = mapped_column(primary_key=True)
    email_address: Mapped[str]
    user_id: Mapped[int] = mapped_column(ForeignKey("user_account.id"))
    user: Mapped["User"] = relationship(back_populates="addresses")
    def __repr__(self) -> str:
        return f"Address(id={self.id!r}, email_address={self.email_address!r})"

Base.metadata.create_all(app.engine)

Documentation

For more information on how to use BlazeNet, please refer to the documentation.

Contributing

Contributions are welcome! If you find a bug or have a feature request, please open an issue or submit a pull request.

License

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

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

blaze-net-1.1.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

blaze_net-1.1.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file blaze-net-1.1.1.tar.gz.

File metadata

  • Download URL: blaze-net-1.1.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.6

File hashes

Hashes for blaze-net-1.1.1.tar.gz
Algorithm Hash digest
SHA256 56322cf4d4649cd121749ba646f8c929997445a020150412162177213ef7f3f3
MD5 ef59130a3163fb0dc79a2b2fc0f008f5
BLAKE2b-256 dc62295a8481ba907eff541bfcf482f52d7ddd69ccd59ded1d14035aebaa1a5c

See more details on using hashes here.

File details

Details for the file blaze_net-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: blaze_net-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.6

File hashes

Hashes for blaze_net-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e43e7c90076d85c1c2bb78d59fd377fd898bff83f7af8eaaca4298afc646cabc
MD5 f3857e4d85387aee0e793335f4bcb1f9
BLAKE2b-256 4d83295768c23f2f4a86f876b5de9c9b37a6904b097e728260936a845a14b5cf

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