{"id":21565282,"url":"https://github.com/sandeepkv93/python-flask-sample-app","last_synced_at":"2025-06-11T17:02:38.224Z","repository":{"id":41961037,"uuid":"159252042","full_name":"sandeepkv93/python-flask-sample-app","owner":"sandeepkv93","description":"Starter code for Python Flask and Deployment in Heroku","archived":false,"fork":false,"pushed_at":"2022-04-21T23:05:21.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T05:17:51.084Z","etag":null,"topics":["flask","herokuapp","procfile","python-3"],"latest_commit_sha":null,"homepage":"https://flaskdemobasic.herokuapp.com","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sandeepkv93.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-27T00:35:22.000Z","updated_at":"2022-04-21T23:05:08.000Z","dependencies_parsed_at":"2022-08-12T00:41:07.221Z","dependency_job_id":null,"html_url":"https://github.com/sandeepkv93/python-flask-sample-app","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sandeepkv93/python-flask-sample-app","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandeepkv93%2Fpython-flask-sample-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandeepkv93%2Fpython-flask-sample-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandeepkv93%2Fpython-flask-sample-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandeepkv93%2Fpython-flask-sample-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sandeepkv93","download_url":"https://codeload.github.com/sandeepkv93/python-flask-sample-app/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandeepkv93%2Fpython-flask-sample-app/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259301676,"owners_count":22836975,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flask","herokuapp","procfile","python-3"],"created_at":"2024-11-24T10:19:05.851Z","updated_at":"2025-06-11T17:02:38.201Z","avatar_url":"https://github.com/sandeepkv93.png","language":"Python","readme":"# Creating Flask App and deploying it in Heroku\n## Live Demo - https://flaskdemobasic.herokuapp.com\n\n## Create a Flask App\n1. Create a virtual environment\n    - In Windows\n    ```shell\n    virtualenv env\n    cd env\\Scripts\n    .\\activate\n    ```\n\n    - In Linux/Mac\n    ```shell\n    virtualenv env\n    source env/bin/activate\n    ```\n2. Install Flask Module\n    ```shell\n    pip install Flask --upgrade\n    ```\n\n3. Create a .gitignore file and add the following lines\n    ```\n    __pycache__/\n    *.py[cod]\n    .vscode\n    env/\n    ```\n\n3. Sample Flask app which returns current Date\n    ```python\n    from flask import Flask\n    from datetime import datetime\n    app = Flask(__name__)\n\n    @app.route('/')\n    def func():\n        return str(datetime.now())\n\n    if __name__ == '__main__':\n        app.run()\n    ```\n4. Run the app\n    ```shell\n    python app.py\n    ```\n    When you goto http://localhost:5000/ you should be able to see current date and time.\n\n## Deploying this app in Heroku\n1. Create a new file and name it as **Procfile** in the project's root folder and add the following text\n    ```\n    web: gunicorn app:app\n    ```\n\n2. Add **guicorn** module and other installed modules to requirements.txt\n    ```shell\n    pip install gunicorn --upgrade\n    pip freeze \u003e requirements.txt\n    ```\n\n3. Specify a python runtime. Example: python-3.6.2\n    - Create a file called **runtime.txt** in the project's root folder and add the following text\n    ```\n    python-3.6.2\n    ```\n\n4. Create a heroku app\n    ```shell\n    heroku create flaskdemoapp\n    ```\n\n5. Initialize git and add remote as heroku\n    ```shell\n    git init\n    git remote add prod git@heroku.com:flaskdemoapp.git\n    ```\n\n6. Commit and push\n    ```shell\n    git add .\n    git commit -m \"Your message\"\n    git push -u prod master\n    ```\n\n7. Incase if you had not added public key, then\n    ```shell\n    heroku login #Username \u0026 Password\n    heroku keys:add ~/.ssh/id_rsa.pub\n    ```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsandeepkv93%2Fpython-flask-sample-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsandeepkv93%2Fpython-flask-sample-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsandeepkv93%2Fpython-flask-sample-app/lists"}