Skip to main content

A lightweight and highly customizable Python framework for building web applications

Project description

Mango Framework

License

Introduction

Mango is a lightweight Python framework for building web applications. It provides a simple and intuitive way to handle routing, render HTML templates, and serve files. With Mango, you can quickly set up a web server and define routes to handle different HTTP requests. It is made to be accessible and highly modifiable even by beginners to learn and eventually move on to more mature frameworks such as Flask or Bottle. You only need python3 to run Mango and nothing else.

Features

  • Easy routing configuration
  • Rendering HTML templates
  • Serving static files
  • Handling JSON data
  • Handling of basic form data
  • Lightweight and minimal dependencies
  • Suitable for small to medium-sized web applications
  • Human readible code even beginners could modify
  • Integrated basic ORM for DB functions
  • Integrated basic Template engine Shake
  • Handling of file uploads

Installation

Mango can be easily installed via pip:

pip install mango-framework

Usage

  1. Import the necessary modules and functions from Mango:
from mango import route, run, render, send_json, send_file, get_json, save_file
  1. Define your routes using the @route() decorator:
@route('/')
def index():
    return "Hello, Mango!"
  1. Get JSON data:
@route('/post')
def post(post):
    user = get_json(post)
    return f"Hello, {user['name']}!"
  1. Send JSON data:
@route('/send')
def send():
    return send_json({'name':'john'})
  1. Send a file for the user to download:
@route('/download')
def download():
    return send_file('image.jpeg')
  1. Render the HTML to the user (now supports shake without the class):
@route('/render')
def render():
    return render('index.html')

### New shake rendering

@route('/render')
def render():
    return render('index.html',{'name':'john'})
  1. Get form data:
@route('/form')
def form(form_data):
    name = get_data(form_data,'name')
    return f"Hello, {name}!"
  1. Get file upload (only takes single file uploads, with no other form data.):
@route('/upload')
def upload(file):
    save_file(file,'article.pdf')
    return "Saved file successfully"
  1. Run the Mango server:
run()

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

mango-framework-0.8.3.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

mango_framework-0.8.3-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file mango-framework-0.8.3.tar.gz.

File metadata

  • Download URL: mango-framework-0.8.3.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for mango-framework-0.8.3.tar.gz
Algorithm Hash digest
SHA256 9ee94e981aa5d4f8dfa83d9570ecb429ff6048ddc8d975c14143f7d6b5087113
MD5 609315f34949d4373d8b86afa44e94e8
BLAKE2b-256 a08f1776fbacebb12e97da69dcd48709363cba16a027dfa4f8fa08fe3e22135d

See more details on using hashes here.

File details

Details for the file mango_framework-0.8.3-py3-none-any.whl.

File metadata

File hashes

Hashes for mango_framework-0.8.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b8fe5d63ed8cdd02424ba6c32246ee1f9f92bd1f9e70d406a96e13706921f677
MD5 ee49df83c75606da6780a1c76514e758
BLAKE2b-256 75ea5772a08fa7244b9e1efb3b5e11111185dbcc516e3341aeb38fe98c9062aa

See more details on using hashes here.

Supported by

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