Tuesday, August 4, 2026

SQL Operations

Here is the Bash command to run a SQL script on a PostgreSQL server in Ubuntu Linux :

psql -U steven -d nama_database -f hapus_tinta_masuk.sql

This is a Linux terminal command to compile C++ source code:

g++ main.cpp -o my_app `pkg-config gtkmm-3.0 --cflags --libs` -lpqxx -lpq

Here is how to log in as the postgres user in Linux distributions like Arch Linux, Debian, Ubuntu, or Kali Linux. Accessing the postgres account is necessary to configure and manage your PostgreSQL server.

First, switch from your standard user account to the root user:

sudo su

Next, switch from the root account to the postgres user:

sudo su postgres

Below is the command to switch directly to the postgres user using a single command:

sudo -i -u postgres

Below is the command to view all users in a PostgreSQL server:

\du

Below is the command to view all available databases on a PostgreSQL server:

\l

Below is a SQL command for a PostgreSQL server that creates a new user named 'steven' with the password 'rahasia' and grants them permission to create databases:

CREATE USER steven WITH PASSWORD 'rahasia' CREATEDB;

Thursday, June 27, 2024

Autodesk AutoCAD : Cara Mematikan ACWebbrowser

Cara Mematikannya :

https://forums.autodesk.com/t5/maya-forum/what-is-acwebbrowser-exe-and-how-do-i-disable-it/td-p/6285733

Wednesday, May 22, 2024

Debian : Python programming using Virtual Environment

In Debian 12, to install modules like Flask, we have to create a virtual environment first.


To achieve this goal, we need a command to install pip3 on Debian 12. The command is as follows:


apt install python3-pip


To install the virtual environment, you can do this via the command:


apt instal python3-venv


This is the basic source code for Flask programming :

 from flask import Flask  
 aplikasi = Flask(__name__)  
 @aplikasi.route('/')  
 def halaman1():  
   return 'Web dari Virtual Environment'  
 if __name__ == '__main__':  
   aplikasi.run(host='0.0.0.0',port=8547,debug=True)  

Wednesday, April 17, 2024

Python : Using Modules to Consume JSON Data from RESTful APIs

This is the source code for creating a RESTful API server that will send data in JSON format over the network.
 from flask import Flask, render_template, request, url_for, redirect, jsonify  
 from jinja2 import Template, Environment, FileSystemLoader  
 import csv  
 import sys  
 import json  
 aplikasi = Flask(__name__)  
 @aplikasi.route('/data')  
 # ini adalah source code untuk membuat server RESTFUL API yang akan mengirimkan data dalam bentuk JSON di jaringan  
 def halaman1():  
   data = {}  
   with open('/home/steven/proyekFlask/latihan15/templates/file2.csv','r') as file:  
     pembacaCSV = csv.DictReader(file)  
     for rows in pembacaCSV:  
       key = rows['nomer']  
       data[key] = rows  
     return jsonify(data)  
 if __name__ == '__main__':  
   aplikasi.run(host="0.0.0.0",port=8543,debug=True)  

The following source code is used to consume JSON data sent by the RESTful API server. The RESTful API server is also created using the Python language.


 from flask import Flask  
 from flask_restful import Resource, Api  
 from flask_cors import CORS  
 import requests  
 aplikasi = Flask(__name__)  
 CORS(aplikasi)  
 # ini adalah program komputer untuk mengkonsumsi data JSON yang di kirimkan oleh server lain  
 @aplikasi.route('/', methods=['GET'])  
 def tampilData():  
   r = requests.get('http://1.1.3.4:8543/data')  
   return r.json()  
 if __name__ == '__main__':  
   aplikasi.run(host="0.0.0.0",port=8544,debug=True)  

Next, we will learn everything about flask_restful. So that we can learn various things related to RESTful API.

Thursday, March 28, 2024

Python : Learning to Connect Between the OS Module and Flask

We will start to integrate Flask with other Python programming code, in this case between Flask and the OS module.


For the first one, we learn to use the OS module.


 import os  
 alamatFolder = os.getcwd()  
 print("Lokasi Folder Saat ini : ", alamatFolder)  


 from flask import Flask, render_template, request, url_for, redirect  
 from jinja2 import Template, Environment, FileSystemLoader  
 import mariadb  
 import sys  
 import os  
 aplikasi = Flask(__name__)  
 @aplikasi.route('/')  
 def halaman1():  
   return render_template("halaman4.html")  
 if __name__ == '__main__':  
   aplikasi.run(host="0.0.0.0",port=8543,debug=True)  

This is the initial source code for displaying a message box from JavaScript, using a server made with Flask.


 <!DOCTYPE html>  
 <html>  
      <head>  
           <meta name="viewport" content="width=device-width, initial-scale=1">  
           <style>  
                .button {  
                     background-color: #04AA6D;  
                     border: none;  
                     color: white;  
                     padding: 15px 32px;  
                     text-align: center;  
                     text-decoration: none;  
                     display: block;  
                     font-size: 16px;  
                     margin: 10px 10px;  
                     cursor: pointer;  
                     -webkit-transition-duration: 0.4s;  
                     transition-duration: 0.4s;  
                }  
                .button2:hover {  
                     box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24), 0 17px 50px 0 rgba(0,0,0,0.19)  
                }  
           </style>  
      </head>  
      <body>  
           <button class="button button2" type="button" onclick="tampilkanPesan()">Uji Coba OS dan Flask</button>  
           <script>  
                function tampilkanPesan() {  
                     alert("Menampilkan Kotak Pesan")  
                }  
           </script>  
      </body>  
 </html>  

We will try to build data delivery over the network using a RESTful API. In building the server and backend RESTFUL API, we use the Python programming language. We will use JavaScript to build the UI. JavaScript will also be used to consume JSON data sent through the RESTFUL API. JavaScript will be used to build AJAX technology.


 import json  
 from flask import Flask  
 import mariadb  
 import sys  
 aplikasi = Flask(__name__)  
 @aplikasi.route('/')  
 # di bawah ini adalah source code untuk mengirimkan data dalam bentuk JSON ke jaringan dan ditampilkan di browser  
 def restApi1():  
   return json.dumps({'nama':'alesandro','e-mail':'alesandro@toto.com'})  
 if __name__ == '__main__':  
   aplikasi.run(host="0.0.0.0",port=8543,debug=True)  

The following is the source code for reading a text file. The results of the reading will then be displayed on the web page. Alternatively, the results of the reading can be sent using a RESTful API. Once the reading results are converted to JSON, they will be displayed on the web page using AJAX.


Python
 from flask import Flask, render_template, request, url_for, redirect  
 from jinja2 import Template, Environment, FileSystemLoader  
 import mariadb  
 import sys  
 aplikasi = Flask(__name__)  
 @aplikasi.route('/')  
 def halaman1():  
   file = open('/home/steven/proyekFlask/latihan15/templates/file1.txt','r')  
   angka1 = file.read()  
   file.close()  
   return render_template("halaman5.html", angka1 = angka1)  
 if __name__ == '__main__':  
   aplikasi.run(host="0.0.0.0",port=8543,debug=True)  

HTML
 <!DOCTYPE html>  
 <html>  
      <head>  
      </head>  
      <body>  
           <p>{{ angka1 }}<p>  
      </body>  
 </html>  

Wednesday, March 27, 2024

JavaScript : Combining Python with Javascript to Run Python Source Code on an HTML Page

We are currently learning how to combine Python and Javascript programming code to run a command on a web page.
 from flask import Flask, render_template, request, url_for, redirect  
 from jinja2 import Template, Environment,FileSystemLoader  
 import mariadb  
 import sys  
 aplikasi = Flask(__name__)  
 @aplikasi.route('/')  
 def halaman1():  
   return render_template("halaman2.html")  
 if __name__ == '__main__':  
   aplikasi.run(host="0.0.0.0",port=8543,debug=True)  

 <!DOCTYPE html>  
 <html>  
      <head>  
           <meta name="viewport" content="width=device-width, initial-scale=1">  
           <style>  
                .button {  
                     background-color: #04AA6D;  
                     border: none;  
                     color: white;  
                     padding: 15px 32px;  
                     text-align: center;  
                     text-decoration: none;  
                     display: block;  
                     font-size: 16px;  
                     margin: 10px 10px;  
                     cursor: pointer;  
                     -webkit-transition-duration: 0.4s;  
                     transition-duration: 0.4s;  
                }  
                .button2:hover {  
                     box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24), 0 17px 50px 0 rgba(0,0,0,0.19);  
                }  
           </style>  
      </head>  
      <body>  
           <button class="button button2" onclick="document.getElementById('cetakTanggal').innerHTML = Date()">Uji Coba Javascript 1</button>  
           <p id="cetakTanggal"></p>  
      </body>  
 </html>  

Tuesday, March 26, 2024

Python : Basic Source Code to Create a Web Page Link to Display a Table

This source code will be further developed to display a table containing data from MariaDB.


This is the Python source code to connect two HTML pages through a web link :


 from flask import Flask, render_template, request, url_for, redirect  
 from jinja2 import Template, Environment, FileSystemLoader  
 import mariadb  
 import sys  
 aplikasi = Flask(__name__)  
 @aplikasi.route('/')  
 def halaman1():  
   return render_template("halaman1.html")  
 @aplikasi.route('/halaman2')  
 def halaman2():  
   return render_template("halaman2.html")  
 if __name__ == '__main__':  
   aplikasi.run(host='0.0.0.0',port=8543,debug=True)  

This is the source code for the first HTML page :


 <!DOCTYPE html>  
 <html>  
      <head>  
           <meta name="viewport" content="width=device-width, initial-scale=1">  
           <style>  
           </style>  
      </head>  
      <body>  
           <h1>Halaman 1</h1>  
                <a href="{{ url_for('halaman2')}}">Halaman 2</a>  
      </body>  
 </html>  

This is the source code for the second HTML page :


 <!DOCTYPE html>  
 <html>  
      <head>  
           <meta name="viewport" content="width=device-width, initial-scale=1">  
      </head>  
      <body>  
           <h1>Halaman 2</h1>  
           <a href="{{ url_for('halaman1')}}">Halaman 1</a>  
      </body>  
 </html>