Set up your app and repository
Back to home
On this page
You can start with an existing Flask app, or generate a new app using Cookiecutter.
Note
If you already have a Flask app, jump straight to initializing your Git repository.
Optional: Generate a Flask project with Cookiecutter
-
To generate a Flask project with Cookiecutter, run the following command:
Terminalcookiecutter https://github.com/cookiecutter-flask/cookiecutter-flask.gitAlternatively, if you’ve already generated a Flask project with Cookiecutter before, indicate the specific template you want to use:
Terminalcookiecutter cookiecutter-flask -
To configure your Flask project, follow the prompts and enter responses similar to the following:
[1/10] full_name (): John Doe [2/10] email (): john.doe@upsun.com [3/10] github_username (): jdoe [4/10] project_name (): my_flask_project [5/10] app_name (): my_flask_app [6/10] project_short_description (): A demonstration project [7/10] use_pipenv (): n [8/10] python_version (): 3.11 [9/10] node_version (): 18 [10/10] use_heroku (): NKeep note of your
app_namefor later use. After you’ve gone through all the prompts, your Flask project is generated.
Initialize your Git repository
-
Navigate to your Flask project directory. If youโve generated your Flask project with Cookiecutter, run the following command, using the
app_namedefined previously:Terminalcd app_name -
To initialize the contents of the directory as a Git repository, run the following command:
Terminalgit initBy default, Git uses
masteras the name for the initial branch. To change the default branch name, rungit branch -m NEW_BRANCH_NAME.