Giter VIP home page Giter VIP logo

helzheng123 / azure_flask_deployment Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 1.97 MB

Hands-on experience setting up a Flask application, integrate it with data processing via Pandas, and deploy the app on Azure App Service. Check Screenshots folder to see the deployment.

Home Page: https://helen-504-flask.azurewebsites.net/

License: The Unlicense

Python 9.44% HTML 90.56%
azure azure-app-service flask-application html jinja pandas

azure_flask_deployment's Introduction

azure_flask_deployment

This is an introduction to Azure and Flask deployment.

Deployed URL for my application: https://helen-504-flask.azurewebsites.net/

Guide on how to set up and deploy the application:

Set up:

  1. Create a new repository with the name called azure_flask_deployment on Github (check off "Add a README.md file"). Once the repository has been created, go to <> Code and copy the link. Open your Google Shell and in the terminal, use the command git clone <URL> (replace URL with the link you copied from your repository). Go to File-->Open and find your cloned repository.

  2. Create a new app.py file. For this application, you will need to have the following in your file:

from flask import Flask, render_template
import pandas as pd

app = Flask(__name__)

@app.route('/')
def index():
    return render_template('base.html')

@app.route('/about')
def aboutpage():
    return render_template('about.html')

df = pd.read_csv('data/healthy_lifestyle_city_2021.csv')
@app.route('/data')
def data(data=df):
    data = data.head(15)
    return render_template('data.html', data=data)

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

If needed, you can change the df = pd.read_csv('data/healthy_lifestyle_city_2021.csv') line with your own dataset name.

  1. Since we are dealing with HTML, we will need a templates folder. Create a new folder and name it templates. In this folder, we will need to make about.html, base.html, and data.htmlfiles. In each of these files, the templates were taken from here. You can customize it to tailor your application.

  2. Create a requirements.txt file. Type in faker,pandas, and flask each in separate lines. Make sure to save!

  3. In the Google Shell terminal, type in: git add .. Afterward, type in git commit -m '<add a message>'and replace the add a message portion with your own comment. Then type in git push to send the repo back to Github.

Deploy Application via Azure:

  1. In the Google Shell terminal, you will need to install AZURE CLI with this: curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash. Copy and paste the line in and enter.

  2. Then type in az. Type in az login --use-device-code and wait for a link and a code to appear in the terminal. Copy the code and press the link to log in to your Azure account. This will help connect your Google Shell with your Azure account.

  3. Log in to your Azure account. Navigate to Resource Group and create a new Resource Group with a unique name. Press Review and Create.

  4. Head back to Google Shell and in the terminal, type in az account list --output table to make sure you have the correct subscription for your Azure account. Make sure your subscription is correct. In my case, the subscription is Azure for Students. If the subscription has not defaulted to the desired one, type in az account set --subscription <paste the desired SubscriptionId here>.

  5. Now type in az group list.

  6. Type in az webapp up --name <replace with what you would like to name the webapp> --runtime PYTHON:3.9 --sku B1. Once entered, the Azure app service will create the web app for you. This step may take a while to load.

  7. Once the service completes the deployment, you can go to App Service in the Azure site to deploy the web app. Choose the appropriate web app. Then you will be redirected to the overview of the web app. The link for your application will be found at the Default domain. Click on the link and you will now be redirected to your web application.

  8. ๐Ÿ˜ƒ Congrats! You have deployed your web application! ๐Ÿ˜ƒ

If you do make any changes, make sure to do the three git commands (shown in step 5 of Setup) in the Google Shell terminal.

azure_flask_deployment's People

Contributors

helzheng123 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.