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)