Skip to main content

AutoFlask simplifies Flask project setup, automating the creation of essential files and directories with just one command.

Project description

asciicast

AutoFlask

AutoFlask is a command-line utility designed to streamline the creation of Flask applications by generating a basic project structure with essential configurations. This tool sets up a Flask project skeleton, allowing developers to jumpstart their Flask application development with best practices in mind.

Installation

To install AutoFlask, you can use pip:

pip install autofl

Ensure you have Flask installed in your environment or virtualenv where you plan to run AutoFlask.

Usage

To create a new Flask application structure, navigate to your project directory in the terminal and run:

autoflask init

This command generates the following project structure:

/project
    /static
    /templates
    config.py
    routes.py
    app.py

Generated Project Structure

static

This directory is intended for static files like CSS, JavaScript, and image files. Flask will serve files from this directory under the /static endpoint.

templates

The templates directory holds your Jinja2 templates. Flask will render these templates when serving pages, allowing for dynamic content generation.

config.py

A configuration file that initializes your Flask app with necessary settings. It includes a placeholder for the secret key and a sample function, create_app, to instantiate and configure your Flask application. This file also demonstrates registering a blueprint for your routes and handling a basic 404 error.

Example create_app function:

from flask import Flask

def create_app():
    app = Flask(__name__)
    app.config["SECRET_KEY"] = 'YOUR SECRET KEY'
    from routes import routes
    app.register_blueprint(routes, url_prefix="/")
    return app

routes.py

Defines your Flask routes using a Blueprint. It's a starting point for your application's endpoints.

Example route:

from flask import Blueprint

routes = Blueprint("routes", __name__)

@routes.route("/")
def index():
    return "<h1>Welcome To Your Flask Application!</h1>"

app.py

The entry point for running your Flask application. It imports the app from config.py and runs the server.

Example usage:

from config import create_app

app = create_app()

if __name__ == '__main__':
    app.run(port=5000, debug=True)

Contributing

Contributions to AutoFlask are welcome!

License

MIT License

Acknowledgements

Thank you to the Flask community for providing the inspiration and foundation for building web applications with ease.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

AutoFL-1.3.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

AutoFL-1.3-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file AutoFL-1.3.tar.gz.

File metadata

  • Download URL: AutoFL-1.3.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.1

File hashes

Hashes for AutoFL-1.3.tar.gz
Algorithm Hash digest
SHA256 2f625f490952b452bcf0d854047530f14adf54eb69b3e39a6ac3cd76f109d3a8
MD5 4524b04e99136dd90870c4585be381f7
BLAKE2b-256 0dc19dec4b25bedfba4c1ddd3b2ea4e34344603da6a6b8d79dd3b83946e3a110

See more details on using hashes here.

File details

Details for the file AutoFL-1.3-py3-none-any.whl.

File metadata

  • Download URL: AutoFL-1.3-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.1

File hashes

Hashes for AutoFL-1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5b752083d274d2012984e91daa1efa123e695a781a2034150e0069d620217935
MD5 a83a7ef7d75c60aac0f5c00d639fb097
BLAKE2b-256 d0662685a0237064a4d397bf2edd5fb409e2f121a1860e2b9afaee26853f3d9d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page