Free Tier: Install Flask on an Ubuntu VM
In this tutorial, you use an Oracle Cloud Infrastructure Free Tier account to set up an Ubuntu instance. Then, you set up a virtual environment for your host. Finally, you install Flask, a lightweight web application framework for Python.
Key tasks include how to:
- Set up a compartment for your development work.
- Install your Ubuntu Linux instance and connect it to your Virtual Cloud Network
(VCN).
- Set up an Oracle Cloud Infrastructure virtual cloud network and related network services required for your host to connect to the internet.
- Set up
ssh
encryption keys to access your Ubuntu Linux Server.
- Configure ingress rules for your VCN.
- Install Flask on your VM.
- Create a Hello World Python application.
- Test your application.
Here is a simplified diagram of the setup for your Linux VM.
For additional information, see:
Before You Begin
To successfully complete this tutorial, you must have the following:
Requirements
- An Oracle Cloud Infrastructure Free Tier account. Start for free.
- A MacOS, Linux, or Windows computer with
ssh
support installed.
1. Set up a Compartment for Development
Configure a compartment for your development.
Create a compartment for the resources that you create in this tutorial.
- Sign in to the Oracle Cloud Infrastructure Console.
- Open the navigation menu and click Identity & Security. Under Identity, click Compartments.
- Click Create Compartment.
- Fill in the following information:
- Name:
<your-compartment-name>
- Description:
Compartment for <your-description>.
- Parent Compartment:
<your-tenancy>(root)
- Name:
- Click Create Compartment.
Reference: Create a compartment
2. Install an Ubuntu Linux Instance
Use the Create a VM Instance workflow to create a new compute instance.
The workflow does several things when installing the instance:
- Creates and installs a compute instance running Ubuntu Linux.
- Creates a VCN with the required subnet and components needed to connect the Ubuntu Linux instance to the internet.
- Creates an
ssh
key pair you use to connect to the instance.
To get started installing an instance with the Create a VM instance workflow, follow these steps:
The steps provided are for a Free Tier account. If you are using a paid account, the steps might differ from those shown here.
3. Enable Internet Access
The Create a VM Instance wizard automatically creates a VCN for your VM. You add an ingress rule to your subnet to allow internet connections on port 5000.
Follow these steps to select your VCN's public subnet and add the ingress rule.
4. Create a Flask Application
Next, set up Flask on your Ubuntu Linux instance and then create and run a Flask application.
To set up Flask with Python 3, perform the following steps:
What's Next
You have successfully installed Flask and created a Python application on Oracle Cloud Infrastructure using an Ubuntu VM.
To explore more information about development with Oracle products check out these sites: