Skip to content

pamelafox/simple-flask-server-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repository includes a very simple Python Flask web site, made for demonstration purposes only.

Opening the project

This project has Dev Container support, so it will be be setup automatically if you open it in Github Codespaces or in local VS Code with the Dev Containers extension.

If you're not using one of those options for opening the project, then you'll need to:

  1. Create a Python virtual environment and activate it.

  2. Install requirements:

    python3 -m pip install -r requirements.txt

Local development

  1. Run the server:

    python3 -m flask run --port 50505 --debug
  2. Click 'http://127.0.0.1:50505' in the terminal, which should open the website in a new tab.

  3. Try the index page, try '/hello?name=yourname', and try other paths.


Deployment

This repo is set up for deployment on Azure App Service using the configuration files in the infra folder.

Steps for deployment:

  1. Sign up for a free Azure account

  2. Install the Azure Dev CLI. (If you opened this repository in a devcontainer, that part will be done for you.)

  3. Login to your Azure account:

    azd auth login
  4. (Optional) If you'd like to use the free SKU instead of the basic SKU, run:

    azd env set USE_FREE_SKU true
  5. Provision and deploy all the resources:

    azd up

    It will prompt you to login and to provide a name (like "flask-app") and location (like "eastus"). Then it will provision the resources in your account and deploy the latest code.

  6. When azd has finished deploying, you'll see an endpoint URI in the command output. Visit that URI, and you should see the front page of the app! 🎉 If you see an error, open the Azure Portal from the URL in the command output, navigate to the App Service, select Logstream, and check the logs for any errors.

  7. When you've made any changes to the app code, you can just run:

    azd deploy

Costs

Pricing varies per region and usage, so it isn't possible to predict exact costs for your usage.

You can try the Azure pricing calculator for the resources:

  • Azure App Service: Basic Tier with 1 CPU core, 1.75 GB RAM. Pricing

⚠️ To reduce unnecessary costs, remember to take down your app if it's no longer in use, either by deleting the resource group in the Portal or running azd down.

If you would like to avoid any potential costs, you can configure this app to deploy to the Free Tier of App Service by running this command before provisioning any resources:

azd env set USE_FREE_SKU true

About

A very simple Python Flask server (classroom example)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages