Name | blendedux JSON |
Version |
0.1.4
JSON |
| download |
home_page | None |
Summary | A cross-platform design theme framework. |
upload_time | 2024-07-03 05:53:52 |
maintainer | None |
docs_url | None |
author | Himanshu |
requires_python | None |
license | None |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
Blended python flask is a web framework, it is a python module that lets you develop web applications easily. Flask is very Pythonic. It is easy to get started with Flask, because it does not have a huge learning curve. On top of that it is very explicit, which increases readability. Simply, you can install the blended python flask, specify the path of your theme, run the server and can browse your website which is running on a Blended theme.
## Installation
pip install blendedux
## Usages
#### Setup of Blended Python Flask
Run the following commands sequentially. First will create virtual environment, second will take you to the newly created virtual environment, third will activate the virtual environment and fourth will install blendedux inside the virtual environment.
```
python -m virtualenv env_name
cd env_name
Scripts\activate
pip install blendedux
```
#### Create a file name app.py in the root directory and paste below line of code and save.
```
from flask import Flask
from blendedUx import *
from blendedUx.blended_flask.bl_flask_app import Bl_Flask
PACKAGE_DIR = "themes-directory"
app = Bl_Flask(__name__, package_dir= PACKAGE_DIR)
user_name = 'user_name'
theme_name = 'theme_name'
password = ''
theme = app.load(theme_name, user_name)
@app.route("/css/<path:path>")
@get_css('css_path')
def css():
pass
@app.route("/media/<path:path>")
@get_media('media_path')
def media():
pass
@app.route("/js/<path:path>")
@get_js('js_path')
def js():
pass
@app.route('/')
def home(**kwargs):
"""
"""
context = theme
file_content = get_template('home.html')
try:
return render_code(file_content, context)
except UnicodeDecodeError:
return render_code(file_content.decode('utf-8'), context)
if __name__ == "__main__":
app.run()
```
Note: Please specify your path in the package directory. You can point to your working directory which you have set up during cli and make sure that blended directory structures is there and it has a valid blended theme. Password is optional.
For an example:
```
PACKAGE_DIR = "C:/Users/themes"
user_name = 'blended'
theme_name = 'base_theme'
password = ''
```
#### How to Include the theme into your flask application?
Create a templates directory in the root and create a home.html inside the templates directory and paste below line of code in the home.html and save.
```
{% extends theme.template.home|template %}
{% block title %}
<title>My Blended Site </title>
{% endblock title %}
{% block css %}
<link rel="stylesheet" href="{{css(theme)}}">
{% endblock %}
```
Note: It is extending the home template of the theme. Extending a predefined Blended template should allow you to add a new page in your flask application. This host template is extending the theme base template named as home.html. Base templates are part of Blended theme which resides in the html directory.For an example:
```
{% extends theme.template.home|template %}
```
#### Run the Flask Server
python app.py
Just load the below URL (http://localhost:5000/) in a browser to see the output.
## API
#### CSS ENDPOINT
By default, the /static directory will serve the static contents. If you want to provide the path of CSS then you can change this by following API:
```
@app.route("/css/<path:path>")
@get_css("css_path")
def css():
pass
```
Note: User will need to give the absolute path in the css_path like this @get_css("C:/blendedUx/static/css")
#### Js ENDPOINT
By default, the /static directory will serve the static contents. If you want to provide the path of js then you can change this by following API:
```
@app.route("/js/<path:path>")
@get_js("js_path")
def js():
pass
```
Note: User will need to give the absolute path in the js_path like this @get_js("C:/blendedUx/static/js")
#### Media ENDPOINT
Add Media Endpoint
By default application will host the media at /static directory in the root but you can change this by following API:
```
@app.route("/media/<path:path>")
@get_media("media_path")
def media():
pass
```
Note: User will need to give the absolute path in the media_path like this @get_media("C:/blendedUx/static/media")
#### Add Route
```
@app.route("/")
def home(**kwargs):
"""
"""
context = theme
file_content = get_template("home.html")
try:
return render_code(file_content, context)
except UnicodeDecodeError:
return render_code(file_content.decode("utf-8"), context)
```
Note: It is registering the root URL for your application. This route is rendering a home.html template file by accepting the Blended theme context object. The home.html is a Blended host template and you can add many more as per your requirements in templates directory and then define a route for that template based on above code snippet in app.py.
For more details go to [Quickstart Python Flask](https://hub.blended.co/learn/quickstart_blended_flask/)
## License
MIT
Raw data
{
"_id": null,
"home_page": null,
"name": "blendedux",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "Himanshu",
"author_email": "<hbhadu@cognam.com>",
"download_url": "https://files.pythonhosted.org/packages/f5/1b/3ba85c8e13e14b0c97868987d177d635e17c2678596ffaf173069298ed29/blendedux-0.1.4.tar.gz",
"platform": null,
"description": "Blended python flask is a web framework, it is a python module that lets you develop web applications easily. Flask is very Pythonic. It is easy to get started with Flask, because it does not have a huge learning curve. On top of that it is very explicit, which increases readability. Simply, you can install the blended python flask, specify the path of your theme, run the server and can browse your website which is running on a Blended theme.\r\n\r\n## Installation\r\n\r\npip install blendedux\r\n\r\n## Usages\r\n\r\n#### Setup of Blended Python Flask\r\n\r\nRun the following commands sequentially. First will create virtual environment, second will take you to the newly created virtual environment, third will activate the virtual environment and fourth will install blendedux inside the virtual environment.\r\n```\r\npython -m virtualenv env_name\r\ncd env_name\r\nScripts\\activate\r\npip install blendedux\r\n```\r\n\r\n#### Create a file name app.py in the root directory and paste below line of code and save.\r\n\r\n```\r\nfrom flask import Flask\r\nfrom blendedUx import *\r\nfrom blendedUx.blended_flask.bl_flask_app import Bl_Flask\r\n\r\nPACKAGE_DIR = \"themes-directory\"\r\n\r\napp = Bl_Flask(__name__, package_dir= PACKAGE_DIR)\r\n\r\nuser_name = 'user_name'\r\ntheme_name = 'theme_name'\r\npassword = ''\r\n\r\ntheme = app.load(theme_name, user_name)\r\n\r\n@app.route(\"/css/<path:path>\")\r\n@get_css('css_path')\r\ndef css():\r\n pass\r\n@app.route(\"/media/<path:path>\")\r\n@get_media('media_path')\r\ndef media():\r\n pass\r\n@app.route(\"/js/<path:path>\")\r\n@get_js('js_path')\r\ndef js():\r\n pass\r\n\r\n@app.route('/')\r\ndef home(**kwargs):\r\n \"\"\"\r\n \"\"\"\r\n context = theme\r\n file_content = get_template('home.html')\r\n try:\r\n return render_code(file_content, context)\r\n except UnicodeDecodeError:\r\n return render_code(file_content.decode('utf-8'), context)\r\n\r\nif __name__ == \"__main__\":\r\n app.run()\r\n```\r\nNote: Please specify your path in the package directory. You can point to your working directory which you have set up during cli and make sure that blended directory structures is there and it has a valid blended theme. Password is optional.\r\nFor an example:\r\n```\r\nPACKAGE_DIR = \"C:/Users/themes\" \r\nuser_name = 'blended' \r\ntheme_name = 'base_theme' \r\npassword = '' \r\n```\r\n#### How to Include the theme into your flask application?\r\n\r\nCreate a templates directory in the root and create a home.html inside the templates directory and paste below line of code in the home.html and save.\r\n\r\n```\r\n{% extends theme.template.home|template %} \r\n{% block title %}\r\n<title>My Blended Site </title> \r\n{% endblock title %} \r\n{% block css %}\r\n<link rel=\"stylesheet\" href=\"{{css(theme)}}\">\r\n{% endblock %}\r\n```\r\nNote: It is extending the home template of the theme. Extending a predefined Blended template should allow you to add a new page in your flask application. This host template is extending the theme base template named as home.html. Base templates are part of Blended theme which resides in the html directory.For an example:\r\n```\r\n{% extends theme.template.home|template %}\r\n```\r\n#### Run the Flask Server\r\n\r\npython app.py\r\n\r\nJust load the below URL (http://localhost:5000/) in a browser to see the output.\r\n\r\n\r\n## API\r\n\r\n#### CSS ENDPOINT\r\nBy default, the /static directory will serve the static contents. If you want to provide the path of CSS then you can change this by following API:\r\n```\r\n @app.route(\"/css/<path:path>\")\r\n @get_css(\"css_path\") \r\n def css(): \r\n pass\r\n```\r\nNote: User will need to give the absolute path in the css_path like this @get_css(\"C:/blendedUx/static/css\")\r\n\r\n#### Js ENDPOINT\r\nBy default, the /static directory will serve the static contents. If you want to provide the path of js then you can change this by following API:\r\n```\r\n @app.route(\"/js/<path:path>\")\r\n @get_js(\"js_path\") \r\n def js(): \r\n pass\r\n```\r\nNote: User will need to give the absolute path in the js_path like this @get_js(\"C:/blendedUx/static/js\") \r\n\r\n#### Media ENDPOINT\r\n\r\nAdd Media Endpoint\r\nBy default application will host the media at /static directory in the root but you can change this by following API:\r\n```\r\n @app.route(\"/media/<path:path>\")\r\n @get_media(\"media_path\") \r\n def media(): \r\n pass\r\n```\r\nNote: User will need to give the absolute path in the media_path like this @get_media(\"C:/blendedUx/static/media\") \r\n\r\n#### Add Route\r\n```\r\n @app.route(\"/\")\r\n def home(**kwargs):\r\n \"\"\"\r\n \"\"\"\r\n context = theme \r\n file_content = get_template(\"home.html\")\r\n try:\r\n return render_code(file_content, context)\r\n except UnicodeDecodeError:\r\n return render_code(file_content.decode(\"utf-8\"), context)\r\n```\r\nNote: It is registering the root URL for your application. This route is rendering a home.html template file by accepting the Blended theme context object. The home.html is a Blended host template and you can add many more as per your requirements in templates directory and then define a route for that template based on above code snippet in app.py. \r\n\r\nFor more details go to [Quickstart Python Flask](https://hub.blended.co/learn/quickstart_blended_flask/)\r\n\r\n## License\r\nMIT\r\n\r\n\r\n",
"bugtrack_url": null,
"license": null,
"summary": "A cross-platform design theme framework.",
"version": "0.1.4",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "000bfea06fbafeaef9cea8f261aad990031916323f3a7fed226fa3e83e975ee9",
"md5": "cc8c386f4437023981177ca7e22e3143",
"sha256": "8372e5767d88a440dfebaf2c6c416427d9d1b1af66ad06164a199ffa0e1fff1c"
},
"downloads": -1,
"filename": "blendedux-0.1.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "cc8c386f4437023981177ca7e22e3143",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 545479,
"upload_time": "2024-07-03T05:53:49",
"upload_time_iso_8601": "2024-07-03T05:53:49.218447Z",
"url": "https://files.pythonhosted.org/packages/00/0b/fea06fbafeaef9cea8f261aad990031916323f3a7fed226fa3e83e975ee9/blendedux-0.1.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f51b3ba85c8e13e14b0c97868987d177d635e17c2678596ffaf173069298ed29",
"md5": "1ab8fb5353bf1a10d815ae2b3fd68f08",
"sha256": "e42768dde69c76c790d520526bbf1fe400d9a9a65262d4db243c31a93cbaa62c"
},
"downloads": -1,
"filename": "blendedux-0.1.4.tar.gz",
"has_sig": false,
"md5_digest": "1ab8fb5353bf1a10d815ae2b3fd68f08",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 245233,
"upload_time": "2024-07-03T05:53:52",
"upload_time_iso_8601": "2024-07-03T05:53:52.926276Z",
"url": "https://files.pythonhosted.org/packages/f5/1b/3ba85c8e13e14b0c97868987d177d635e17c2678596ffaf173069298ed29/blendedux-0.1.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-03 05:53:52",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "blendedux"
}