https://github.com/mordy-python/magicweb
Magicweb is a python webframework
https://github.com/mordy-python/magicweb
framework python webframework
Last synced: 2 months ago
JSON representation
Magicweb is a python webframework
- Host: GitHub
- URL: https://github.com/mordy-python/magicweb
- Owner: mordy-python
- License: mit
- Created: 2021-08-26T15:35:28.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-09-09T12:01:08.000Z (over 4 years ago)
- Last Synced: 2025-09-28T12:12:54.196Z (6 months ago)
- Topics: framework, python, webframework
- Language: Python
- Homepage: https://magicweb-docs.web.app/
- Size: 3.87 MB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Magicweb
Magicweb is a simple web framework that is still under developement. It has a simple API to allow you to create your own web application quickly and easily.
view the [documentation](https://magicweb-docs.web.app/).
## Usage
### Installation
To install Magicweb you can run
`pip install Magicweb` or `pip3 install Magicweb`
To install Magicweb from source run
```shell
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.
```python
import magicweb
app = magicweb.Magicweb(__file__)
```
Once our app is instantiated we can add routes
```python
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', response)
```
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
```python
...
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
```python
import magicweb
app = magicweb.Magicweb(__file__)
@app.route('/{name}')
def index(request, response, name):
response.text = "hello " + name
```