• multiple python script in single website without Django

    To create a website with multiple Python scripts without using Django, you can use the Flask framework. Flask is a lightweight web framework that provides flexibility and simplicity for creating web applications. You can organize your project into multiple scripts by modularizing your code into blueprints.

    Here’s a step-by-step guide to create a website with multiple Python scripts using Flask:

    Step 1: Install Flask

    First, install Flask using pip:

    pip install Flask

    Step 2: Create the Flask Application Structure

    Create a directory structure for your Flask application:

    mkdir my_flask_app
    cd my_flask_app
    mkdir templates static

    Create the following files:

    • app.py: Main application file
    • config.py: Configuration file
    • blueprints.py: File to register blueprints
    • Create directories for your modules (e.g., blog and shop), each with its own views.py and __init__.py files.

    Step 3: Main Application File (app.py)

    Create the main application file app.py:

    from flask import Flask
    from blueprints import register_blueprints

    app = Flask(__name__)
    register_blueprints(app)

    if __name__ == '__main__':
    app.run(debug=True)

    Step 4: Configuration File (config.py)

    Create a configuration file config.py:

    class Config:
    DEBUG = True
    SECRET_KEY = 'your_secret_key'

    def init_app(app):
    app.config.from_object(Config)

    Step 5: Blueprints Registration (blueprints.py)

    Create a file blueprints.py to register your blueprints:

    from blog import blog_blueprint
    from shop import shop_blueprint

    def register_blueprints(app):
    app.register_blueprint(blog_blueprint, url_prefix='/blog')
    app.register_blueprint(shop_blueprint, url_prefix='/shop')

    Step 6: Blog Module

    Create a directory blog with __init__.py and views.py.

    blog/__init__.py

    from flask import Blueprint

    blog_blueprint = Blueprint('blog', __name__)

    from . import views

    blog/views.py

    from flask import render_template
    from . import blog_blueprint

    @blog_blueprint.route('/')
    def home():
    posts = [
    {'title': 'First Post', 'content': 'Content of the first post.'},
    {'title': 'Second Post', 'content': 'Content of the second post.'}
    ]
    return render_template('blog/home.html', posts=posts)

    Step 7: Shop Module

    Create a directory shop with __init__.py and views.py.

    shop/__init__.py

    from flask import Blueprint

    shop_blueprint = Blueprint('shop', __name__)

    from . import views

    shop/views.py

    from flask import render_template
    from . import shop_blueprint

    @shop_blueprint.route('/')
    def home():
    products = [
    {'name': 'Product 1', 'description': 'Description of product 1.', 'price': 10.0},
    {'name': 'Product 2', 'description': 'Description of product 2.', 'price': 20.0}
    ]
    return render_template('shop/home.html', products=products)

    Step 8: Templates

    Create the necessary templates.

    templates/blog/home.html






    Blog Home


    Blog Posts



      {% for post in posts %}

    • {{ post.title }}


      {{ post.content }}



    • {% endfor %}



    templates/shop/home.html






    Shop Home


    Products



      {% for product in products %}

    • {{ product.name }}


      {{ product.description }}


      Price: ${{ product.price }}



    • {% endfor %}



    Step 9: Run the Application

    Run your Flask application:

    python app.py

    Navigate to http://127.0.0.1:5000/blog/ to see the blog section and http://127.0.0.1:5000/shop/ to see the shop section.

    Additional Features

    You can further enhance your Flask application by adding:

    1. User Authentication: Use Flask extensions like Flask-Login for managing user authentication.
    2. Database Integration: Use Flask-SQLAlchemy for database integration.
    3. Forms and Validations: Use Flask-WTF for handling forms and validations.
    4. API Development: Use Flask-RESTful for developing RESTful APIs.
    5. Testing: Write unit tests using Flask-Testing or pytest-flask.
    6. Deployment: Deploy your application to production using services like Heroku, AWS, or DigitalOcean.

    By organizing your Flask project with blueprints, you can keep your code modular and maintainable, making it easier to manage as your project grows.

  • WordPress File Permissions and Ownership

    Welcome to the comprehensive guide on WordPress file permissions and ownership. In this step-by-step walkthrough, we will explore how to correctly set file permissions and ownership for your WordPress site. Understanding and configuring these settings properly is essential for maintaining the security and functionality of your WordPress installation. Let’s dive in and learn how to manage file permissions effectively in WordPress.

    1. Understanding File Permissions (#)
    2. WordPress Directory Structure (#)
    3. Setting the Correct Ownership (#)
    4. File Permission Recommendations (#)
    5. Configuring Specific Directories and Files (#)
    6. Changing Permissions (#)
    7. Troubleshooting Permissions (#)

    1. Understanding File Permissions


    File permissions dictate who can perform specific actions on files or directories. In WordPress, there are three primary permissions you’ll encounter:

    • Read (r): Allows reading/viewing of a file or directory
    • Write (w): Permits modifying or deleting a file or directory.
    • Execute (x): Allows executing or running a file or accessing a directory.

    2. WordPress Direcotry Structure


    Before delving into file permissions, let’s understand the key directories in a typical WordPress installation:

    • wp-admin: Contains core files for the WordPress admin area.
    • wp-includes: Holds core WordPress files for functionality.
    • wp-content: Houses user-specific content such as themes, plugins, and uploads.

    3. Setting the Correct Ownership


    It’s crucial to ensure the correct ownership of WordPress files to maintain security and proper functionality. Typically, the web server (e.g., Apache or Nginx) should own the files. Follow these steps to set the ownership correctly:

    • Identify the user running the web server process. For example, on Apache, it may be ‘www-data.’
    • Change ownership recursively for the WordPress directory:chown -R www-data:www-data /path/to/wordpress

    4. File Permission Recommendations


    Here are the recommended file permission settings for WordPress:

    • All directories: 755chmod 755 directory-name
    • All files: 644chmod 644 file-name

    5. Configuring Specific Directories and Files


    Some directories and files require specific permissions for proper functioning. Follow these guidelines:

    • wp-config.php: Set permissions to 600chmod 600 wp-config.phpto protect sensitive configuration information.
    • wp-content/uploads: Set permissions to 775chmod 775 /path/to/wp-content/uploadsto allow WordPress to write/upload files.
    • wp-content/plugins and wp-content/themes: Use 755chmod 755 /path/to/wp-content/plugins and chmod 755 /path/to/wp-content/themesto enable file modifications.

    6. Changing Permissions


    To modify permissions, you can use the chmod command in your terminal or an FTP client. Here’s an example of changing permissions using chmod:

    • To set permissions to 644 for a file:chmod 644 filename
    • To set permissions to 755 for a directory:chmod 755 directory-name

    7. Troubleshooting Permissions


    If you encounter issues related to file permissions, consider the following:

    • Check ownership: Ensure the web server user (e.g., ‘www-data’) owns the WordPress files.
    • Double-check permissions: Verify that the file permissions are correctly set according to the recommendations.
    • Plugins and themes: Temporarily deactivate plugins or switch to a default theme to identify any conflicts.
  • Apple is preparing to bring AirPods with camera

    Apple is preparing to bring AirPods with camera

    Apple company is preparing to bring new models of AirPods with camera. An infrared camera will be found in the new AirPods. It does Face ID of iPhone and iPad. This is a part of Apple’s Vision Pro project. Till now there is no such earbuds in the market which has a camera.

    #apple #technology

  • Will be able to choose custom thumbnail

    Will be able to choose custom thumbnail

    YouTube is going to release an update soon. With this, you will be able to choose a custom thumbnail for a playlist. There is no option to choose a custom thumbnail. According to a media report, the company is working on this feature. It will soon be released for all YouTube users. Custom thumbnail code has been seen in the beta version 9.26.33 of the Android app. Information about the size of custom thumbnails for playlists has also been found in the code.

  • New update for Circle to Search soon

    New update for Circle to Search soon

    A new update is coming for Google’s Circle to Search. After its arrival, Circle to Search will also scan QR codes and barcodes. The company will release this feature with beta version. Google first launched the Circle to Search feature with Samsung’s Galaxy S24 series. Apart from Google Pixel, it was also released for other phones. Circle to Search – Identifies things visible in a photo or video with AI.

  • Create picture with AI on WhatsApp

    Create picture with AI on WhatsApp

    WhatsApp is working on another new AI generated feature. With its help, users can create their own photo using Meta AI in the app. Website WebInfo has given this information. According to the report, optional feature will be available. Users will get a section of AI Generated for You in the app. Will allow taking a set of photos. It will be used to create Meta AI images. Users will have to take setup photos for this.

  • How to protect yourself?
    Verify before sharing. If contacted by unknown sources, check credentials independently
    Don’t dial codes or send SMS to unsolicited callers
    Never share sensitive info or click unsolicited links
    Don’t trust urgent requests from unknown callers
    Never pay or share personal information during investigations
    Monitor your bank statements and heed alerts for any suspicious transactions
  • system last reboot time command ubuntu

    who -b command : Shows the time of last Linux system boot time.
    last -x|grep shutdown | head -1 : Use the last reboot and this command to display all the previous reboot date and time for the system.12 Dec 2020

  • Youtube Premium users will get new features

    Youtube Premium users will get new features

    Youtube company is working on a new plan for YouTube Premium subscription. YouTube is also adding new features for Premium subscribers. The AI-powered Jump Ahead feature recently launched for Android users will also come for iOS users in the next few weeks. Currently, the company provides only five plans in the country. On subscribing, the user can get the facility of downloading, YouTube music library and watch ad-free videos.

  • Google will make changes in search results

    Google will make changes in search results

    Google is going to make a big change in its search results. According to the report, it is going to stop scrolling the search results. However, it has also been claimed that it is not going to be completely closed, but some restrictions will be imposed on it. The process of shutting down this feature for desktop has started. Currently, there is an option to search continuously in Google search results. When you search for something on Google, its results keep appearing continuously.