integrated flask template

master
Malar Kannan 2017-08-09 12:13:31 +05:30
parent fffed7a048
commit 016f5801df
12 changed files with 9958 additions and 1 deletions

104
.gitignore vendored
View File

@ -19,3 +19,107 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Created by https://www.gitignore.io/api/python
### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# dotenv
.env
# virtualenv
.venv
venv/
ENV/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# End of https://www.gitignore.io/api/python

20
app/__init__.py Normal file
View File

@ -0,0 +1,20 @@
# -*- encoding: utf-8 -*-
"""
Python Aplication Template
Licence: GPLv3
"""
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
app = Flask(__name__,static_url_path='',static_folder='build')
#Configuration of application, see configuration.py, choose one and uncomment.
#app.config.from_object('configuration.ProductionConfig')
app.config.from_object('app.configuration.DevelopmentConfig')
#app.config.from_object('configuration.TestingConfig')
db = SQLAlchemy(app) #flask-sqlalchemy
from app import views, models

29
app/configuration.py Normal file
View File

@ -0,0 +1,29 @@
# -*- encoding: utf-8 -*-
"""
Python Aplication Template
Licence: GPLv3
"""
class Config(object):
"""
Configuration base, for all environments.
"""
DEBUG = False
TESTING = False
DATABASE_URI = 'sqlite:///application.db'
BOOTSTRAP_FONTAWESOME = True
SECRET_KEY = "MINHACHAVESECRETA"
CSRF_ENABLED = True
#Get your reCaptche key on: https://www.google.com/recaptcha/admin/create
#RECAPTCHA_PUBLIC_KEY = "6LffFNwSAAAAAFcWVy__EnOCsNZcG2fVHFjTBvRP"
#RECAPTCHA_PRIVATE_KEY = "6LffFNwSAAAAAO7UURCGI7qQ811SOSZlgU69rvv7"
class ProductionConfig(Config):
DATABASE_URI = 'mysql://user@localhost/foo'
class DevelopmentConfig(Config):
DEBUG = True
class TestingConfig(Config):
TESTING = True

18
app/forms.py Normal file
View File

@ -0,0 +1,18 @@
# -*- encoding: utf-8 -*-
"""
Python Aplication Template
Licence: GPLv3
"""
from flask.ext.wtf import Form, TextField, TextAreaField, DateTimeField, PasswordField
from flask.ext.wtf import Required
class ExampleForm(Form):
title = TextField(u'Título', validators = [Required()])
content = TextAreaField(u'Conteúdo')
date = DateTimeField(u'Data', format='%d/%m/%Y %H:%M')
#recaptcha = RecaptchaField(u'Recaptcha')
class LoginForm(Form):
user = TextField(u'Usuário', validators = [Required()])
password = PasswordField(u'Senha', validators = [Required()])

39
app/models.py Normal file
View File

@ -0,0 +1,39 @@
# -*- encoding: utf-8 -*-
"""
Python Aplication Template
Licence: GPLv3
"""
from app import db
class Post(db.Model):
id = db.Column(db.Integer, primary_key=True)
title = db.Column(db.String(80))
body = db.Column(db.Text)
pub_date = db.Column(db.DateTime)
category_id = db.Column(db.Integer, db.ForeignKey('category.id'))
category = db.relationship('Category',
backref=db.backref('posts', lazy='dynamic'))
def __init__(self, title, body, category, pub_date=None):
self.title = title
self.body = body
if pub_date is None:
pub_date = datetime.utcnow()
self.pub_date = pub_date
self.category = category
def __repr__(self):
return '<Post %r>' % self.title
class Category(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(50))
def __init__(self, name):
self.name = name
def __repr__(self):
return '<Category %r>' % self.name

27
app/views.py Normal file
View File

@ -0,0 +1,27 @@
# -*- encoding: utf-8 -*-
"""
Python Aplication Template
Licence: GPLv3
"""
from flask import url_for, redirect, render_template, flash, g, session
from app import app
@app.route('/')
def index():
return app.send_static_file('index.html')
@app.route('/api/addpost',methods=['POST'])
def walle_morph():
word = request.args.get('word','water')
pos_req = request.args.get('pos','N')
pos = pos_req if pos_req != '' else 'N';
return json.dumps(get_morph(word,pos))
@app.route('/api/xmlfiles')
def walle_xmlfiles():
xml_files = map(os.path.basename,glob.glob(xmlDir+'*.xml'))
return json.dumps(xml_files)
# ====================

14
create_env.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
## Requirements
## gcc, make, Python 2.5+, python-pip, virtualenv
## Instalation
## Create a virtualenv, and activate this:
virtualenv env
source env/bin/activate
pip install -r requirements.txt
python run.py

9664
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,8 @@
"react-router-dom": "^4.1.2",
"react-scripts-ts": "2.5.0",
"react-semantic-ui": "^0.2.0",
"semantic-ui-react": "^0.71.3"
"semantic-ui-react": "^0.71.3",
"yarn": "^0.27.5"
},
"devDependencies": {},
"scripts": {

16
requirements.txt Normal file
View File

@ -0,0 +1,16 @@
click==6.7
Flask==0.12.2
Flask-FlatPages==0.6
Flask-Restless==0.17.0
Flask-SQLAlchemy==2.2
itsdangerous==0.24
Jinja2==2.9.6
Markdown==2.6.8
MarkupSafe==1.0
mimerender==0.6.0
python-dateutil==2.6.1
python-mimeparse==1.6.0
PyYAML==3.12
six==1.10.0
SQLAlchemy==1.1.13
Werkzeug==0.12.2

17
run.py Normal file
View File

@ -0,0 +1,17 @@
# -*- encoding: utf-8 -*-
"""
Python Aplication Template
Licence: GPLv3
"""
import os
from app import app
#----------------------------------------
# launch
#----------------------------------------
if __name__ == "__main__":
port = int(os.environ.get("PORT", 5000))
app.run(host='0.0.0.0', port=port)

View File

@ -0,0 +1,8 @@
import * as React from 'react';
// import { Segment } from 'semantic-ui-react';
export const About: React.StatelessComponent<{}> = () => {
return (
null
);
}