A lightweight and highly customizable Python framework for building web applications
Project description
Mango Framework
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
- Setting custom 404 error pages
Installation
Mango can be easily installed via pip:
pip install mango-framework
Usage
- Import the necessary modules and functions from Mango:
from mango import route, run, render, send_json, send_file, get_json, save_file, set_404
- Define your routes using the @route() decorator:
@route('/')
def index():
return "Hello, Mango!"
- Get JSON data:
@route('/post')
def post(post):
user = get_json(post)
return f"Hello, {user['name']}!"
- Send JSON data:
@route('/send')
def send():
return send_json({'name':'john'})
- Send a file for the user to download:
@route('/download')
def download():
return send_file('image.jpeg')
- 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'})
- Get form data:
@route('/form')
def form(form_data):
name = get_data(form_data,'name')
return f"Hello, {name}!"
- 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"
- Change the default 404 Page:
set_404("<h1> not here ! </h1>")
## or pass an HTML or any file directly
set_404("404.html")
- Run the Mango server:
run()
- Latest Revisions in version 0.9.1
- Added more User friendly error handling
- Updated the default HTML to automatically switch between dark/light mode
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mango-framework-0.9.1.tar.gz
.
File metadata
- Download URL: mango-framework-0.9.1.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6913b92390e7bcfb8b155b6efc5ef9d9b7ba54640f68bbcb6b7b56e380cdddc2 |
|
MD5 | 0350be4693fd441e5df7e4aa9615df89 |
|
BLAKE2b-256 | 064595e4e9884169cadcb3ce29c8e21494875cd198c4902648a891febf1dd5a1 |
File details
Details for the file mango_framework-0.9.1-py3-none-any.whl
.
File metadata
- Download URL: mango_framework-0.9.1-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f7cce6291c4ec229ccdfd69e12c7b127dd0ebd1a7dbcb70a11dcd15300b002a |
|
MD5 | d46a6e85eff7357c9b69cdb82eb0e4a4 |
|
BLAKE2b-256 | 1e85d9d8c1166ff57b754079a25db8eb6ce5e72c919f967206e47968f4672c64 |