Giter Site home page Giter Site logo

create-flask-app's People

Contributors

gl0deanr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

create-flask-app's Issues

createflaskapp.config does not exists.

Hi!
I'm 'husudosu' from Reddit r/flask. After cloning your project I tried to start the migration procedure but config.py file missing by default. I'd suggest using creating config.py by default on the package and maybe use a class-based Config.

I imagine something like this:

# This is config.py

# In my opinion better practice to use .env files instead requiring users/developers to edit .py files before starting out with a project.
# you could load environment file based on FLASK_DEBUG environment variable. If FLASK_DEBUG not present on the system, it means we running on production config.
# dotenv is a 3rd party lib https://pypi.org/project/python-dotenv/
from dotenv import load_dotenv

if os.environ.get("FLASK_DEBUG") == 1:
    load_dotenv("development.env")
else:
    load_dotenv("production.env")

class Config:
    SQLALCHEMY_DATABASE_URI = os.environ.get("SQLALCHEMY_DATABASE_URI")
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    SECRET_KEY = os.environ.get("SECRET_KEY")
    # Other options...
# createflaskapp.__init__.py
# You import Config class and 

app.config.from_object(Config)

# And you don't need to set SECRET_KEY, DATABASE URI or other options on your __init__.py.

Note: This implementation only a draft, so this is not the full code. I'm using pattern like this on my production projects.

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.