-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
# Custom | ||
venv/ | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from flask import Flask, render_template | ||
from flask.ext.bootstrap import Bootstrap | ||
from flask.ext.sqlalchemy import SQLAlchemy | ||
from config import config | ||
|
||
bootstrap = Bootstrap() | ||
db = SQLAlchemy() | ||
|
||
def create_app(config_name): | ||
app = Flask(__name__) | ||
app.config.from_object(config[config_name]) | ||
config[config_name].init_app(app) | ||
|
||
bootstrap.init_app(app) | ||
db.init_app(app) | ||
|
||
# attach routes and custom error pages | ||
from .main import main as main_blueprint | ||
app.register_blueprint(main_blueprint) | ||
|
||
return app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from flask import Blueprint, render_template | ||
|
||
main = Blueprint('main', __name__) | ||
|
||
@main.route('/') | ||
def index(): | ||
return render_template('index.html') |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{% extends "bootstrap/base.html" %} | ||
|
||
{% block title %}Sirius{% endblock %} | ||
|
||
{% block navbar %} | ||
<div class="navbar navbar-inverse" role="navigation"> | ||
<div class="container"> | ||
<div class="navbar-header"> | ||
<button type="button" class="navbar-toggle" | ||
data-toggle="collapse" data-target=".navbar-collapse"> | ||
<span class="sr-only">Toggle navigation</span> | ||
<span class="icon-bar"></span> | ||
<span class="icon-bar"></span> | ||
<span class="icon-bar"></span> | ||
</button> | ||
<a class="navbar-brand" href="{{ url_for('main.index') }}">Sirius</a> | ||
</div> | ||
<div class="navbar-collapse collapse"> | ||
<ul class="nav navbar-nav"> | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="container"> | ||
{% for message in get_flashed_messages() %} | ||
<div class="alert alert-warning"> | ||
<button type="button" class="close" data-dismiss="alert">×</button> | ||
{{ message }} | ||
</div> | ||
{% endfor %} | ||
|
||
{% block page_content %}{% endblock %} | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block title %}Sirius - Index{% endblock %} | ||
|
||
{% block page_content %} | ||
<h1>Hello, World!</h1> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import os | ||
basedir = os.path.abspath(os.path.dirname(__file__)) | ||
|
||
|
||
class Config: | ||
SECRET_KEY = os.environ.get('SECRET_KEY') or 'this is the lp2 secret' | ||
SQLALCHEMY_COMMIT_ON_TEARDOWN = True | ||
|
||
@staticmethod | ||
def init_app(app): | ||
pass | ||
|
||
class DevelopmentConfig(Config): | ||
DEBUG = True | ||
SQLALCHEMY_DATABASE_URI = os.environ.get('DEV_DATABASE_URL') or \ | ||
'sqlite:///' + os.path.join(basedir, 'data-dev.sqlite') | ||
|
||
config = { | ||
'development': DevelopmentConfig, | ||
|
||
'default': DevelopmentConfig | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
|
||
if os.path.exists('.env'): | ||
print('Importing environment from .env...') | ||
for line in open('.env'): | ||
var = line.strip().split('=') | ||
if len(var) == 2: | ||
os.environ[var[0]] = var[1] | ||
|
||
from app import create_app, db | ||
from flask.ext.script import Manager, Shell | ||
from flask.ext.migrate import Migrate, MigrateCommand | ||
|
||
app = create_app(os.getenv('FLASK_CONFIG') or 'default') | ||
manager = Manager(app) | ||
migrate = Migrate(app, db) | ||
|
||
|
||
def make_shell_context(): | ||
return dict(app=app, db=db, User=User, Follow=Follow, Role=Role, | ||
Permission=Permission, Post=Post, Comment=Comment) | ||
manager.add_command("shell", Shell(make_context=make_shell_context)) | ||
manager.add_command('db', MigrateCommand) | ||
|
||
|
||
if __name__ == '__main__': | ||
manager.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Flask==0.10.1 | ||
Flask-Bootstrap==3.2.0.2 | ||
Flask-Migrate==1.2.0 | ||
Flask-SQLAlchemy==2.0 | ||
Flask-Script==2.0.5 | ||
Jinja2==2.7.3 | ||
Mako==1.0.0 | ||
MarkupSafe==0.23 | ||
SQLAlchemy==0.9.7 | ||
Werkzeug==0.9.6 | ||
alembic==0.6.7 | ||
itsdangerous==0.24 |