This commit is contained in:
Dita Aji Pratama 2025-06-10 16:17:34 +07:00
parent c5c9f1f287
commit 5a7ecfb1ed

View File

@ -1,33 +1,34 @@
## Instalasi dan Implementasi Web API ## Instalasi dan Penggunaan Web API
### Instalasi
1. Install python 1. Install python
2. Buka CMD atau Command-prompt 2. Buka CMD atau Command-prompt
3. cd nama/folder/costapy (di copy) 3. cd nama/folder/costapy (di copy)
4. Jalankan command ini di CMD: 4. Jalankan command ini di CMD:
```sh ```sh
py -m pip install --upgrade pip py -m pip install --upgrade pip
py -m pip install bottle py -m pip install bottle
py -m pip install beaker py -m pip install beaker
py -m pip install mako py -m pip install mako
py -m pip install mysql-connector py -m pip install mysql-connector
py -m pip install bcrypt py -m pip install bcrypt
py -m pip install pyjwt[crypto] py -m pip install pyjwt[crypto]
``` ```
5. Buka folder project pake VSCode 5. Buka folder project pake VSCode
6. Buka file di config/server.py 6. Buka file di config/server.py
7. servernya ganti dari 'gunicorn' ke 'wsgiref' (di save) 7. servernya ganti dari 'gunicorn' ke 'wsgiref' (di save)
8. di CMD jalanin service-nya: ### Penggunaan
Untuk Windows: 8. Buka CMD lalu jalanin service-nya:
- Untuk Windows:
```dos ```dos
cd C:\direktori\folder\kamu cd C:\direktori\folder\kamu
py costa.py py costa.py
``` ```
Untuk Linux/MacOS: - Untuk Linux/MacOS:
```sh ```sh
cd directory/folder/kamu cd directory/folder/kamu
python costapy python costapy
``` ```
9. kalau keluar http://localhost:11000 artinya berhasil 9. kalau keluar output http://localhost:11000 artinya berhasil
10. Install bruno 10. Install bruno
11. bikin collection 11. bikin collection
12. test localhost:11000 12. test localhost:11000
@ -45,7 +46,7 @@ py -m pip install pyjwt[crypto]
- terminal: mariadb -u root -p - terminal: mariadb -u root -p
- MySQL Client Command Prompt: Buka MySQL client lalu masukan password - MySQL Client Command Prompt: Buka MySQL client lalu masukan password
### Implementasi (Di dalam MySQL Client) ### Implementasi (Buat Table di dalam MySQL Client)
1. CREATE DATABASE latihan; 1. CREATE DATABASE latihan;
2. USE latihan; 2. USE latihan;
@ -62,3 +63,9 @@ py -m pip install pyjwt[crypto]
); );
6. SELECT * FROM member; 6. SELECT * FROM member;
7. exit 7. exit
## Pengunaan widuri-client
1. Nyalain Widuri API
2. Ke directory Widuri Client (Contoh: `cd C:\direktori\widuri-api`)
3. Nyalain service Widuri Client: `py -m http.server 12000`
4. buka `localhost:12000` di Browser