Skip to content

Commit

Permalink
add .gitignore file and separate configs
Browse files Browse the repository at this point in the history
  • Loading branch information
xash3000 committed Dec 26, 2015
1 parent eab46d5 commit 33c698a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.pyc
__pycache__
12 changes: 12 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import os
# -*- coding: utf-8 -*-

WEBSITENAME = "زيزفون"
DATABASE = os.path.join(os.getcwd(), "zayzafoun.db")
DEBUG = False
# generate secret key with os.urandom()
SECRET_KEY = '\xf9\xab\xc4\xe8\xc2\xc1\xc1\xc6\xb6\xa3:\x99\xa8\x19O\xad*!\x9e\x0ei\x07\xabd'
USERNAME = 'admin'
PASSWORD = 'default'
# Don't forget to change the disqus name! Or the comments section won't show up.
DISQUSNAME = "tajribython"
23 changes: 9 additions & 14 deletions zayzafoun.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,30 @@
from flask import Flask, request, session, g, redirect, url_for, abort, render_template, current_app
from contextlib import closing

# configuration
WEBSITENAME = "زيزفون"
DATABASE = "" + os.getcwd() + '/' + 'zayzafoun.db' + ""
DEBUG = False
SECRET_KEY = 'DFSGSY$#%#^%&5375$#fhgf37I365OY8*PYK'
USERNAME = 'admin'
PASSWORD = 'default'
# Don't forget to change the disqus name! Or the comments section won't show up.
DISQUSNAME = "tajribython"


# Creating the application.
app = Flask(__name__)
app.config.from_object(__name__)
app.config.from_object("config")

def cleanCode(text):
return text

@app.context_processor
def variables_def():
return dict(websiteName=unicode(WEBSITENAME, "utf-8"), websiteUrl=request.url_root[:-1], disqusName=DISQUSNAME, currentUrl=request.path, cleanCode=cleanCode)
return dict(
websiteName=unicode(app.config["WEBSITENAME"], "utf-8"),
websiteUrl=request.url_root[:-1],
disqusName=app.config["DISQUSNAME"],
currentUrl=request.path,
cleanCode=cleanCode
)

def connect_db():
return sqlite3.connect(app.config['DATABASE'])


def init_db():
with closing(connect_db()) as db:
with app.open_resource("" + os.getcwd() + '/' + 'schema.sql' + "", mode='r') as f:
with app.open_resource(os.path.join(os.getcwd(), "schema.sql"), mode='r') as f:
db.cursor().executescript(f.read())
db.commit()

Expand Down

0 comments on commit 33c698a

Please sign in to comment.