Wednesday, April 16, 2025

Important commands for Set up the Environment in VSCode

 Important commands for Set up the Environment in VSCode

1.open vscode create new folder

2.open new terminal 

3.create virtual enviroment
python3 -m venv <name of venv>
<name of venv > =you can give any name 
or
Pip install Virtualenv
          virtualenv <virtualenv -name>

6.Activate VirtualEnvironment
          venv/scripts/activate

5.Install requirements

           pip install -r requirment.txt
7.Run the Flask application
            python3 app.py (or) main.py

8.Check sum Dir commands before viva
          pip install checksumdir

          import checksumdir
          hash = checksumdir.dirhash("folder_name")
          print(hash)

9.For MAD2 project
MailHog
https://github.com/mailhog/MailHog
sudo apt-get -y install golang-go
go install github.com/mailhog/MailHog@latest

10.Celery
celery -A app:celery_app worker -l INFO

Running Celery in Two Terminals (WSL + VENV)

Terminal 1 – Celery Worker

         celery -A app:celery_app worker -l INFO

1.celery: starts Celery
2.-A app:celery_app:
  • app is the Python file or package where your Flask app lives

  • celery_app is the Celery instance inside that file

3.worker: starts the worker, which runs the background tasks
4.-l INFO: sets log level to INFO so you can see what's happening

Terminal 2 – Celery Beat (Scheduler)

                celery -A app:celery_app beat -l INFO
beat: runs the scheduler that triggers tasks on a schedule (e.g., every hour, daily, etc.)

 celery_app.config_from_object(app.config["CELERY"])

In your Flask app, you probably have some Celery config like this:

app.config["CELERY"] = {
    "broker_url": "redis://localhost:6379/0",
    "result_backend": "redis://localhost:6379/0",
    "task_serializer": "json",
    "timezone": "UTC"
}
celery_app = Celery(__name__)
celery_app.config_from_object(app.config["CELERY"]

Tells Celery to load configuration from your Flask app’s config
app.config["CELERY"] is a dictionary of settings (like broker URL, result backend, etc.)

INFO-links:
https://docs.celeryq.dev/en/stable/userguide/periodic-tasks.html
celery_app.config_from_object(app.config["CELERY"])


 12.Design links to create random images for profile using this 
https://www.figma.com/design/8gofrho5qM79pdqMSLGk71/Untitled-(1)?node-id=0-1&t=xthanTKKkvRNE4TT-0
<img src="https://picksum.photos/500/500" alt="photo of campaign">

MAD2
Redis server- (WSL)
Frontend -(CMD)
Backend -(WSL) (VENV)
MailHog -(WSL)


MAD1-TechStack
  1. Python – The core programming language used to build the backend logic of the application.

  2. Flask – A lightweight web framework in Python used to create web routes, handle user requests, and manage the server-side of the application.

  3. HTML – Used to structure the content of web pages, forming the base layout of the frontend.

  4. Bootstrap – A frontend CSS framework used to style HTML components, make the layout responsive, and provide a clean user interface.

  5. Flask-RESTful==0.3.9 – An extension for Flask that helps build RESTful APIs quickly and cleanly, making it easy to interact with external clients or services.

  6. Flask-SQLAlchemy==3.0.2 – A Flask extension that integrates SQLAlchemy with Flask, allowing easy interaction with the SQLite database through Python objects.

  7. Jinja2==3.1.2 – The templating engine used by Flask to inject dynamic content (like user data or campaign info) into HTML pages.

  8. SQLAlchemy==1.4.45 – The Object Relational Mapper (ORM) used to define models and manage database operations using Python code instead of raw SQL.

  9. Werkzeug==2.2.2 – A WSGI utility library used internally by Flask, and also helps in securely handling things like password hashing and file uploads.


DB Schema Design Tools
           
4.https://drawsql.app


No comments:

Post a Comment

Mangerial Economics Quiz1 solutions Guide

Mangerial Economics Quiz1 solutions Guide  solutions watch on you tube channel