Added configuration file and wsgi file

email
AndroidDrew 7 years ago
parent 7c88fe83c4
commit b317c8f4c2

3
.gitignore vendored

@ -1,3 +1,6 @@
# virtualenv
env
# Pycharm
.idea

@ -0,0 +1,4 @@
; config.ini
[user]
BCRYPT_LOG_ROUNDS : 13

@ -5,9 +5,9 @@ from apistar.frameworks.wsgi import WSGIApp as App
from apistar.handlers import docs_urls, static_urls
from apistar.interfaces import Router
from render import JSONRenderer
from commands import commands
from models.schema import Base, Cookie
from cookie_api.render import JSONRenderer
from cookie_api.commands import commands
from cookie_api.models.schema import Base, Cookie
def get_cookies(session: Session):
@ -57,14 +57,13 @@ routes = [
settings = {
'DATABASE': {
'URL': 'postgresql://:@localhost/apistar',
'URL': 'postgresql://apistar:local@localhost/apistar',
'METADATA': Base.metadata
},
'RENDERERS': [JSONRenderer()],
'JWT': {
'SECRET': 'thisisasecret'
},
'BCRYPT_LOG_ROUNDS': 13
}
}
commands = sqlalchemy_backend.commands + commands

@ -1,7 +1,7 @@
from apistar import Command
from apistar.backends.sqlalchemy_backend import Session
from models.schema import User
from cookie_api.models.schema import User
def create_user(session: Session, email, password):

@ -1,3 +1,5 @@
from configparser import ConfigParser
import bcrypt
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String, ForeignKey, DateTime, Boolean, Numeric
@ -6,6 +8,11 @@ from sqlalchemy.sql import expression
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.types import DateTime as DateTimeType
cfg = ConfigParser()
cfg.read('config.ini')
BCRYPT_LOG_ROUNDS = cfg.get('user', 'BCRYPT_LOG_ROUNDS')
# can be moved to models util?
class utcnow(expression.FunctionElement):
@ -55,7 +62,7 @@ class User(DBMixin, Base):
def __init__(self, email, password, admin=False):
self.email = email
self.password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt(13)).decode()
self.password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt(BCRYPT_LOG_ROUNDS)).decode()
self.admin = admin

@ -1,6 +1,6 @@
import json
from models.util import alchemyencoder
from cookie_api.models.util import alchemyencoder
from apistar import http
from apistar.renderers import Renderer

@ -1,18 +1,22 @@
apistar==0.3.6
apistar-jwt==0.1.2
apistar==0.3.9
apistar-jwt==0.2.0
bcrypt==3.1.4
certifi==2017.7.27.1
cffi==1.11.2
chardet==3.0.4
coreapi==2.3.1
colorama==0.3.9
coreapi==2.3.3
coreschema==0.0.4
idna==2.6
itypes==1.1.0
Jinja2==2.9.6
MarkupSafe==1.0
psycopg2==2.7.3.1
py==1.4.34
pycparser==2.18
PyJWT==1.5.3
pytest==3.2.2
pytest==3.2.3
requests==2.18.4
six==1.11.0
SQLAlchemy==1.1.14
uritemplate==3.0.0
urllib3==1.22

@ -0,0 +1,3 @@
if __name__ == "__main__":
from cookie_api.app import app
app.main()
Loading…
Cancel
Save