Giter VIP home page Giter VIP logo

capstone-flask-app-template-seattle-ds-062419's Introduction

Capstone Flask App Template

Part 1: Students Will Be Able To

  • Describe the client-server model
  • Describe the terms "frontend" and "backend"
  • Understand the difference between a static and a dynamic website
  • Understand which part of a Flask app contains Python
  • Understand which part of a Flask app contains HTML and CSS
  • Create a new conda environment and install the requirements for a Flask app
  • Run a Flask app locally
  • View output from server print statements
  • Use the jinja2 templating system to send data from the backend to the frontend of a Flask app

Part 2: Students Will Be Able To

  • Understand the difference between a GET and a POST request
  • Use an HTML form to send data from the frontend to the backend
  • Understand how JavaScript fits into the frontend

Requirements

This repo uses Python 3.6.0. All python packages can be found in the requirements.txt file.

To create a new conda environment to use this repo, run:

conda create --name flask-env --file requirements.txt
conda activate flask-env

You will likely need to install additional packages to support your deployment, e.g. scikit-learn. With the flask-env activated, you can run conda install <package-name>. Once you are ready to deploy, you can generate your own requirements.txt for reproducibility purposes with:

conda list --export > requirements.txt

Running the Flask Application

export FLASK_ENV=development
env FLASK_APP=app.py flask run

Sending Data From the Backend to the Frontend

Let's get the current time:

from time import strftime
time_str = strftime("%m/%d/%Y %H:%M")

Then let's send it to the frontend:

return render_template("index.html", time_info=time_str)

Then on the frontend, display it:

<p>
    Current time: {{time_info}}
</p>

capstone-flask-app-template-seattle-ds-062419's People

Contributors

cenuno avatar hoffm386 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.