Skip to content

Basic Usage

ZABBIX edited this page Sep 15, 2023 · 24 revisions

Basic Usage πŸ’‘

Configure your Project πŸ”§

After creating your project, you'll encounter a file named "project_name.py." Inside this file, you'll find multiple configuration sections. To run the application, simply execute this file.

Base Project structure:

project_name
β”œβ”€β”€ baseapp
β”‚    β”œβ”€β”€ domain
β”‚    β”‚   └── user.py
β”‚    └── views
β”‚        β”œβ”€β”€ base.js
β”‚        └── hacker.py
β”œβ”€β”€ static
β”‚   β”œβ”€β”€ home.py
β”‚   └── base.css
└── templates
β”‚   β”œβ”€β”€ home.py
β”‚   └── hacker.py
β”œβ”€β”€ project_name.py
└── window_logo.ico

Example of setting file:

import os

from pypulse import Window, Aplication
from pypulse.Template import Template

# Defining aplication route
Aplication.Vars.APLICATION_PATH = os.path.dirname(os.path.abspath(__file__))

# Defining the templates and static files places
Template.TEMPLATE_PATH = os.path.join(
    Aplication.Vars.APLICATION_PATH, 'templates')
Template.STATIC_PATH = os.path.join(
    Aplication.Vars.APLICATION_PATH, 'static')

# Setting Aplications
# I you create a new aplication you need to add this here
Aplication.SetAplication('baseapp')
Aplication.SetAplication('user')

# BROWSER SETTINGS
APP_SETTINGS = {
    'title': 'project_name',
    'debug': False,
    'debug_file_name': 'debug.log',
    'window_size_x': 800,
    'window_size_y': 800,
    'icon_path': os.path.join(
        Aplication.Vars.APLICATION_PATH, 'window_logo.ico')
}

# Initializing Browser
browser = Window.LoadBrowser(**APP_SETTINGS)

Exploring How Applications Work in Your Project πŸ—οΈ

Applications in a PyPulse project work as modular components that help you organize and manage different parts of your web application.

  • Project Structure: When working with PyPulse applications, it's strongly advisable to embrace the Domain-Driven Design (DDD) architecture. When initiating a project, PyPulse provides a base application by default, which you have the flexibility to modify as needed. This base application primarily serves as a starting point for your "Hello World" application. The default structure it offers includes
baseapp
β”œβ”€β”€ domain
β”‚   └── user.py
└── views
    β”œβ”€β”€ home.py
    └── hacker.py
Clone this wiki locally