Flask & Django VM by Anarion Technologies
Flask: Flask is a micro web framework for Python that prioritizes simplicity, flexibility, and minimalism while providing the essential tools for building web applications efficiently. Launched in 2010, Flask is designed to give developers the freedom to choose how they structure their applications and which components to integrate, rather than imposing a rigid structure. This is achieved through its lightweight nature, as it comes with only the most basic features out of the box, allowing developers to add extensions for added functionality, such as form validation, user authentication, and database integration.
One of Flask’s standout features is its use of the Jinja2 templating engine, which allows developers to create dynamic web pages with ease. Additionally, Flask’s routing system is straightforward, making it simple to define URL endpoints and map them to Python functions. Flask is particularly well-suited for small to medium-sized applications, RESTful APIs, and rapid prototyping, enabling developers to quickly iterate and test their ideas without the overhead of more complex frameworks. The strong community around Flask ensures a wealth of extensions and resources, making it easier to find solutions and best practices for various development challenges. Flask’s emphasis on developer choice and a modular approach makes it an ideal framework for those who prefer to have control over their development process and want to create tailored solutions.
Django: Django is a high-level Python web framework that encourages rapid development and pragmatic design by providing a comprehensive suite of tools and built-in features to streamline the development process. First released in 2005, Django follows the model-template-view (MTV) architectural pattern, which helps developers separate business logic from user interface concerns, promoting maintainability and scalability. Its “batteries-included” philosophy means that developers have access to a robust set of built-in features right out of the box, including an automatic admin interface, user authentication, URL routing, and a powerful Object-Relational Mapping (ORM) system that simplifies database interactions and allows for seamless data manipulation.
Django places a strong emphasis on security, offering built-in protections against common vulnerabilities such as SQL injection, cross-site scripting (XSS), and cross-site request forgery (CSRF). This focus on security is essential for developing applications that handle sensitive user data, such as e-commerce sites and content management systems. The framework is designed to be scalable, making it suitable for large-scale applications and high-traffic websites. Its extensive documentation, strong community support, and a wide range of third-party packages make it easy for developers to extend its capabilities. Django’s ability to promote best practices in coding, combined with its powerful features and tools, makes it an excellent choice for both novice and experienced developers looking to build robust, scalable web applications efficiently. The framework also integrates well with various front-end technologies, allowing developers to create rich user experiences while maintaining a solid back-end foundation.
To subscribe to this product from Azure Marketplace and initiate an instance using the Azure compute service, follow these steps:
1. Navigate to Azure Marketplace and subscribe to the desired product.
2. Search for “virtual machines” and select “Virtual machines” under Services.
3. Click on “Add” in the Virtual machines page, which will lead you to the Create a virtual machine page.
4. In the Basics tab:
- Ensure the correct subscription is chosen under Project details.
- Opt for creating a new resource group by selecting “Create new resource group” and name it as “myResourceGroup.”
5. Under Instance details:
- Enter “myVM” as the Virtual machine name.
- Choose “East US” as the Region.
- Select “Ubuntu 18.04 LTS” as the Image.
- Leave other settings as default.
6. For Administrator account:
- Pick “SSH public key.”
- Provide your user name and paste your public key, ensuring no leading or trailing white spaces.
7. Under Inbound port rules > Public inbound ports:
- Choose “Allow selected ports.”
- Select “SSH (22)” and “HTTP (80)” from the drop-down.
8. Keep the remaining settings at their defaults and click on “Review + create” at the bottom of the page.
9. The “Create a virtual machine” page will display the details of the VM you’re about to create. Once ready, click on “Create.”
10. The deployment process will take a few minutes. Once it’s finished, proceed to the next section.
To connect to the virtual machine:
1. Access the overview page of your VM and click on “Connect.”
2. On the “Connect to virtual machine” page:
- Keep the default options for connecting via IP address over port 22.
- A connection command for logging in will be displayed. Click the button to copy the command. Here’s an example of what the SSH connection command looks like:
“`
ssh [email protected]
“`
3. Using the same bash shell that you used to generate your SSH key pair, you can either reopen the Cloud Shell by selecting >_ again
or going to https://shell.azure.com/bash.
4. Paste the SSH connection command into the shell to initiate an SSH session.
Anarion Technologies – Flask & Django
Note: Search product on Azure marketplace and click on “Get it now”
Click on Continue
Click on Create
Creating a Virtual Machine, enter or select appropriate values for zone, machine type, resource group and so on as per your choice.
After Process of Create Virtual Machine. You have got an Option Go to Resource Group
Click Go to Resource Group
Click on the Network Security Group: flask-nsg
Click on Inbound Security Rule
Click on Add
Add Port
Add Port
Destination Port Ranges Section* (where default value is 8080)
5000 & 8000
Select Protocol as TCP
Option Action is to be Allow
Click on Add
Click on Refresh
Copy the Public IP Address
SSH in Terminal & run these following commands:
$ sudo su
$ sudo apt update
Verify Version:
Confirm Flask is Working
Create a Simple Flask App: Create a new directory for your Flask app and navigate into it:
$ mkdir flask_app
$ cd flask_app
Create a Python File: Create a file named app.py:
$ nano app.py
Run the Flask App: Run the Flask application:
$ FLASK_APP=app.py flask run –host=0.0.0.0 –port=5000
Access the App: Open a web browser and go to http://ip-address:5000. You should see:
* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
Confirm Django is Working
Create a New Django Project: Create a new directory for your Django project and navigate into it:
$ mkdir django_project
$ cd django_project
Create a New Django Project: Create a new Django project:
$ django-admin startproject myproject
$ cd myproject
Edit settings.py: Open the settings.py file of your Django project:
$ cd myproject
$ nano settings.py
ALLOWED_HOSTS = [‘ip-address’]
Then run the server with your IP address:
$ cd ..
$ python3 manage.py runserver 0.0.0.0:8000
Access the Django App: Open a web browser and go to http://ip-address:8000. You should see the Django welcome page that says:
Flask and Django is working.
ThankYou!!!
All your queries are important to us. Please feel free to connect.
24X7 support provided for all the customers.
We are happy to help you.
Contact Number: +1 (415) 800-4585
Support E-mail: [email protected]