Giter Site home page Giter Site logo

flaskminipro's Introduction

Flask App Template

Quick Setup:

Code to clone and break reference:

git clone https://github.com/upperlinecode/flaskproject
cd flaskproject
rm -rf .git

Code to install Flask (only necessary once):

pip install flask

Code to configure your flask app (run once each time you open a new terminal):

export FLASK_APP=main.py
export FLASK_RUN_HOST=0.0.0.0
export FLASK_RUN_PORT=8080
export FLASK_DEBUG=1

Code to run flask:

flask run

If you're developing in the cs50 IDE, ignore this next part. If you're developing locally, you can sometimes save time on the environment variables, by installing the python-dotenv package, which automatically loads the settings we're currently setting with export:

pip install python-dotenv

troubleshooting

Virtual Environments (optional)

If you're running this locally, you may want to run this program inside a virtual environment - that way changes to your Python configuration don't persist and impact other python programs on your machine. We've also beta tested virtual environments on Codenvy, where it seems to work intermittently - we kept track of some Codenvy tricks to make that easier.

To create a virtual environment (you only need to do this once), run this code in terminal:

python3 -m venv venv

To ENTER your virtual environment (you'll need to do this every time you open up a new terminal), run this code:

. venv/bin/activate

To EXIT your virtual environment (you'll want to do this if you decide to change projects - think of it like shutting this one down), you just need one word:

deactivate

If you're using a virtual environment like Codenvy, the virtual environment produces more problems than it solves, so consider skipping this step.

Python packages

To start, the only package you need to run is flask for (hopefully) obvious reasons.

To install flask, run this code in terminal.

pip install flask

Remember, if you're using a virtual environment, these packages will only be installed IN the virtual environment (which is part of why we don't recommend it in cs50 where we won't need it - students will accidentally forget where they've configured different settings).

Troubleshooting package installation

If your IDE throws errors on either of these commands saying that you aren't authorized, your account may not be authorized to install packages on the IDE you're using, so try adding the 'switch user and do' command ('sudo' for short):

pip install --user flask

The settings will not be stored between sessions, so every time you open a new terminal, you'll need to run these commands, which are stored in the run-variables.md file for your convenience:

export FLASK_APP=main.py
export FLASK_RUN_HOST=0.0.0.0
export FLASK_RUN_PORT=8080
export FLASK_DEBUG=1

After that you should be able to execute the flask run command normally.

flaskminipro's People

Contributors

fm1539 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.