Skip to main content

A simple web framework

Project description

Magicweb

Magicweb is a simple web framework that is still under developement. It currently supports route parameters and html templating but not template ineritance.

Usage

Installation

To install Magicweb you can run pip install Magicweb or pip3 install Magicweb

To install Magicweb from source run

git clone https://github.com/mordy-python/magicweb
cd magicweb
python setup.py install

Run a basic app

To create a simple app we need to import Magicweb and create an app instance we need to add the __file__ variable to the app instance.

import magicweb
app = magicweb.Magicweb(__file__)

Once our app is instantiated we can add routes

import magicweb
app = magicweb.Magicweb(__file__)

@app.route('/')
def index(request, response):
  response.text = "Hello"
@app.route('/rendered')
def rendered(request, response):
  app.render('index.html')

We created two routes, one that returns hello world, and one that renders an html page. All html pages should be in a directory named html, although this can be overrdden when instantiting the App class.

To run our app we need to use the app.run() function

...
run(app)
# to run with a different host/port just add those arguments
# run(app, host='0.0.0.0', port=5000)

We can also create routes with parameters

import magicweb
app = magicweb.Magicweb(__file__)

@app.route('/{name}')
def index(request, response, name):
  response.text = "hello " + name

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

Magicweb-2.0.3.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

Magicweb-2.0.3-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file Magicweb-2.0.3.tar.gz.

File metadata

  • Download URL: Magicweb-2.0.3.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.5

File hashes

Hashes for Magicweb-2.0.3.tar.gz
Algorithm Hash digest
SHA256 32bc918cfb742e025a1cc2137a5f780901cb3e4994ccd98402465c71fca79f2f
MD5 e8b7f702e12863246fe7e1b1597fc9a8
BLAKE2b-256 5add0f11eb998e29fabb3f4f1759cdd257cdee0c3f53f3686c8a9c2ad07545af

See more details on using hashes here.

File details

Details for the file Magicweb-2.0.3-py3-none-any.whl.

File metadata

  • Download URL: Magicweb-2.0.3-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.5

File hashes

Hashes for Magicweb-2.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9639a376ee09eda9013c40c903d2a8a728131084e6b52eea36a7243a947d3c5d
MD5 5576c2a83092717ef09f0563b89d2984
BLAKE2b-256 425097eb8811976953da2fecb8c6a5787eb0fa599492e7242a8edec9e5d2ed56

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