Skip to content
Snippets Groups Projects
Verified Commit 732c9cb4 authored by Sachin Kamath's avatar Sachin Kamath
Browse files

Restructure code and add user model

parent 31e96218
No related branches found
No related tags found
No related merge requests found
......@@ -108,3 +108,4 @@ venv.bak/
# Jetbrains folders
.idea/
migrations/
# -*- coding: utf-8 -*-
__version__ = '0.1'
from flask import Flask
from flask_debugtoolbar import DebugToolbarExtension
# app/__init__.py
import time
from flask_api import FlaskAPI
from flask_sqlalchemy import SQLAlchemy
# local import
from instance.config import app_config
ENV = 'development'
# initialize sql-alchemy
db = SQLAlchemy()
app = Flask('hodor')
app.config['SECRET_KEY'] = 'CHANGE_ME_IN_PRODUCTION'
from hodor.models import *
from hodor.controllers import *
if ENV == 'development':
app.debug = True
toolbar = DebugToolbarExtension(app)
else:
app.debug = False
if app.config['SECRET_KEY'] == 'CHANGE_ME_IN_PRODUCTION':
print("[!] Please change your secret key before running in production");
def create_app(config_name):
app = FlaskAPI(__name__, instance_relative_config=True)
app.config.from_object(app_config[config_name])
app.config.from_pyfile('config.py')
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db.init_app(app)
if config_name != 'production':
for x in range(0,5):
print "*** YOU ARE NOT RUNNING THE APP IN PRODUCTION MODE!! *** CTRL + C TO ABORT. APP WILL RUN IN {} SECONDS".format(5-x)
time.sleep(1)
if config_name == 'production':
app.config['DEFAULT_RENDERERS'] = [
'flask.ext.api.renderers.JSONRenderer',
]
return app
app = create_app('testing')
from hodor.controllers import *
# -*- coding: utf-8 -*-
from hodor import app
from flask import render_template, request
from flask_wtf import FlaskForm
from wtforms import StringField
from wtforms.validators import DataRequired
class CreateForm(FlaskForm):
text = StringField('name', validators=[DataRequired()])
@app.route('/')
def start():
pass
@app.route('/app')
def application():
pass
# -*- coding: utf-8 -*-
from flask import flash
class Printer(object):
def show_string(self, text):
if text == '':
flash("You didn't enter any text to flash")
else:
flash(text + "!!!")
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
from hodor import app
config_name = 'development'
if __name__ == '__main__':
port = int(os.environ.get("PORT", 8080))
app.run('0.0.0.0', port=port)
app.run()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment