Update getting-starter.md

This commit is contained in:
Dita Aji Pratama 2024-08-09 16:04:05 +07:00
parent 0e5052676b
commit c9411947d9
2 changed files with 41 additions and 28 deletions

View File

@ -1,6 +1,6 @@
# CostaPy # CostaPy
Python Web Framework. Build with CherryPy and Mako. a Python WSGI Web Framework. Build with Bottle and Mako.
## License ## License

View File

@ -2,47 +2,60 @@
## Requirement ## Requirement
You need a Python and this libraries to use CostaPy: You need a `git`, `python`, `pip`, and `venv` before using CostaPy.
- cherrypy
- cherrypy-cors
- mako
- mysql-connector
- bcrypt
- pyjwt[crypto]
## Download Install them using the following commands on your `Debian` or `Ubuntu` system.
Download from repository ```bash
sudo apt update
sudo apt install git python3 python3-venv python3-pip
```
git clone https://github.com/ditaAjiPratama/costapy or you can use the following command to install similar packages using `brew`, the package manager for `macOS`:
```bash
brew install git python3
```
Installs Python 3 with `brew`, which includes `python3`, `pip3`, and the `venv` module. If you don't have Homebrew installed on your `macOS`, you can install it first.
or go to the [git downloads page](https://git-scm.com/downloads) and a [Python downloads page](https://www.python.org/downloads/) and download the latest version of git Python for `Windows`.
## Installation ## Installation
You can install it with run this command Download from repository
```bash
git clone https://gitea.ditaajipratama.net/aji/costapy.git
```
sh install.sh Go to the directory and install with this command:
Here is the completed command ```bash
cd costapy
bash install.sh
```
sudo apt-get install -y python3-pip Use `cat install.sh` if you want to see a completed command.
pip install --upgrade pip
pip install cherrypy
pip install cherrypy-cors
pip install mako
pip install mysql-connector
pip install bcrypt
pip install pyjwt[crypto]
## Usage ## Usage
Use this command to start the web service Use this command below to start the web service and it will run on port `11000` by default
```bash
.venv/bin/python3 costa.py costapy-welcome
```
Here, `costapy-welcome` is the label of your service. You can replace it with any name you prefer.
python<ver> costa.py <ip_address> <port> <service_name> ## Trivia
For an example like this - Why must `venv`?
python3 costa.py localhost 80 My_Service `venv` is a module in Python that provides support for creating lightweight, isolated Python environments, known as virtual environments. Each virtual environment has its own installation directories and can have its own versions of Python packages, independent of the system-wide Python environment.
You can use nohup too and running it in the background like this When deploying a Python application, using a virtual environment ensures that only the required packages (and their specific versions) are bundled. This reduces the risk of deploying unnecessary packages or incompatible versions that could lead to runtime errors.
nohup python3 costa.py localhost 80 My_Service & Using `venv` is a widely accepted best practice in the Python community. It encourages good habits in dependency management, ensuring that projects are self-contained and reducing the potential for "dependency hell."
When a project is no longer needed, deleting its virtual environment is straightforward and does not affect other projects or the system's Python environment.
- Why I add `venv` on my `gitignore`?
Committing `venv` to Git is gross. Virtual environments can contain thousands of files and their size can be in gigabytes. Committing them to Git can overload and clutter your source code repo with unnecessary files and cause confusion for anyone trying to clone and run the source code on their machine.