This is an executable python file for creating an basic flask structure. It allows you to save time in the boring part of your initial app and is very useful for newcomers. Can be used for barely anyone, it's as simple as execute the file (yes, it's that simple) It will create the files to you application, so you can just configure as you wish.
The 'app.py' includes basic imports from flask (Flask, render_template, redirect, etc..) and the very basic structure of the app.
It has an simple configurable db file named 'database.db' (sqlite3 as default, new technologies coming soon...)
First Step > Throw the file inside your preferable folder, my example folder will be "Example".
[root]
| [templates]
| | [index]
| | | index.html
| | |
| | [admin]
| | | admin.html
| | |
| | [auth]
| | | login.html
| | | register.html
| | |
| | base.html
| |
| [static]
| | [css]
| | | custom.css
| | |
| | [js]
| | | custom.js
| | |
| app.py
| models.py
| database.db
|
You have to pip install some libraries and having Python installed.
Flask
pip install flask
This will allow you to work with flask (obviously)
Flask-SQLAlchemy
pip install flask-sqlalchemy
This will allow you to work with databases via SQLAlchemy
# Fast Flask @ https://github.com/ngeorgj/fast-flask
from flask import Flask, render_template, url_for, request, redirect
from flask_sqlalchemy import SQLAlchemy
# YOUR APPLICATION
app = Flask(__name__)
# YOUR DATABASE [SQLITE3]
db = SQLAlchemy(app)
db_file = 'database.db'
# FLASK CONFIGURATION
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + db_file
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['SQLALCHEMY_USERNAME'] = 'admin'
app.config['SQLALCHEMY_PASSWORD'] = 'fast-flask'
app.config['SESSION_COOKIE_NAME'] = 'fastflaskisDOPE'
# SECRET KEY [ CHANGE ]
app.secret_key = 'CHANGE.THIS.ASAP'
# AWS
app.config['AWS_SECRET_KEY'] = 'YOUR.KEY.HERE'
app.config['AWS_KEY_ID'] = 'KEY.ID.HERE'
# BASIC ROUTE TO INDEX/INDEX.HTML
@app.route('/')
def index():
return render_template('index/index.html')
# BASIC ROUTE TO ADMIN/ADMIN.HTML
@app.route('/admin')
def admin():
return render_template('admin/admin.html')
# BASIC ROUTE TO AUTH/LOGIN.HTML
@app.route('/login')
def login():
return render_template('auth/login.html')
# BASIC ROUTE TO AUTH/REGISTER.HTML
@app.route('/register')
def register():
return render_template('auth/register.html')
if __name__ == '__main__':
app.run(debug=True)
1 - Create a folder as the "Example" above.
2 - Throw your 'fastflask.py' file inside it.
3 - Execute the file [fastflask.py]
![Alt Text](https://giphy.com/gifs/python-flask-fast-KG635T1tfby9nHFf81)
4 - Choose if you want to server test it (Recommended)
5 - You can close the website and edit your files and start developing with this base.
+ Adding auth system and integration to db for user login. + Make a little movie on the basic usability of the app. + GET SOME VISIBILITY FOR THIS APP! HAHA
If you enjoyed this and it helps you somehow, please leave follow me here on github and spread the word haha!
BTC 36vmLnP61kSgsQcDLpkKDfashea2wTgkr1 |
ETH 0x1Ff8aaB40005eaB0e70AB87b5225f200AF1A3615 |
LTC MRQkoS1kH11PNWwV3YYL5DJn3WZ1yejFAe |