https://github.com/yezz123/pycontent-type
A Python library to access all Supported Content-Types/Media-Types
https://github.com/yezz123/pycontent-type
Last synced: 6 months ago
JSON representation
A Python library to access all Supported Content-Types/Media-Types
- Host: GitHub
- URL: https://github.com/yezz123/pycontent-type
- Owner: yezz123
- License: mit
- Created: 2023-05-26T05:16:47.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-27T22:47:50.000Z (over 1 year ago)
- Last Synced: 2025-03-25T04:32:33.560Z (7 months ago)
- Language: Python
- Size: 58.6 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# pycontent-type
A Python library to access all Supported Content-Types/Media-Types ⚡## Installation
You can add pycontent-type in a few easy steps. First of all, install the dependency:
```shell
$ pip install pycontent-type---> 100%
Successfully installed pycontent-type
```## Usage
We have a simple API to access all the supported content-types:
As known the categories of content-types are:
- `application`
- `audio`
- `font`
- `image`
- `message`
- `model`
- `multipart`
- `text`
- `video`### Get Content-Type by extension
```python
# Get content-type for application
import pycontent_typelen(pycontent_type.application)
>>> 1551
# Get content-type for specific extension using Name
pycontent_type.application.get(Name='json')>>> application(Name='json', Template='application/json')
# Get content-type for specific extension using Template
pycontent_type.application.get(Template='application/xml')>>> application(Name='xml', Template='application/xml')
```The same applies for all the categories, we have 2 ways to get the content-type:
- Using `Name` attribute
- Using `Template` attribute## Development 🚧
### Setup environment 📦
You should create a virtual environment and activate it:
```bash
python -m venv venv/
``````bash
source venv/bin/activate
```And then install the development dependencies:
```bash
# Install dependencies
pip install -e .[test,lint]
```### Run tests 🌝
You can run all the tests with:
```bash
bash scripts/test.sh
```### Format the code 🍂
Execute the following command to apply `pre-commit` formatting:
```bash
bash scripts/format.sh
```## License
This project is licensed under the terms of the MIT license.