Skip to content

Commit 7416068

Browse files
committed
Merge pull request #16 from huxuan/file-structure
Basic file structure constructed, fixing #15 .
2 parents abad1b5 + 3f9d68c commit 7416068

File tree

9 files changed

+494
-0
lines changed

9 files changed

+494
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,6 @@ docs/_build/
5555

5656
# PyBuilder
5757
target/
58+
59+
# Custom
60+
config.py

Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
run:
2+
python run.py
3+
req:
4+
pip install -r requirements.txt
5+
deploy:
6+
service capuhome-api reload
7+
clean:
8+
find . -name '*.pyc' -print0 | xargs -0 rm -f
9+
find . -name '*.swp' -print0 | xargs -0 rm -f
10+
-@sudo rm -rf whoosh_index
11+
permission:
12+
chown -R www-data.www-data .
13+
chown www-data.www-data /tmp/jieba.cache
14+
pyflakes:
15+
pyflakes app config.sample.py run.py
16+
pep8:
17+
pep8 app config.sample.py run.py
18+
pylint:
19+
pylint app config.sample.py run.py
20+
lint: pyflakes pep8 pylint

app/__init__.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
"""
4+
File: __init__.py
5+
Author: huxuan <i(at)huxuan.org>
6+
Description: Initial file for app.
7+
"""
8+
9+
from flask import Flask
10+
11+
app = Flask(__name__) # pylint: disable=invalid-name
12+
app.config.from_object('config')
13+
14+
# commented as for file structure, should recover later.
15+
# from app import models
16+
17+
18+
@app.route('/')
19+
@app.route('/hellworld')
20+
def helloworld():
21+
""" Hello World for app. """
22+
return 'Hello world from {}!'.format(__name__)

app/models.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
"""
4+
File: models.py
5+
Author: huxuan <i(at)huxuan.org>
6+
Description: Models for app.
7+
"""

config.sample.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
"""
4+
File: config.sample.py
5+
Author: huxuan <i(at)huxuan.org>
6+
Description: Configuration file for app.
7+
"""
8+
9+
# Debug or not
10+
DEBUG = True
11+
12+
# Make jsonfiy encode in utf-8.
13+
JSON_AS_ASCII = False
14+
15+
# Secret key.
16+
SECRET_KEY = 'CAPUHOME_Secret_Key'
17+
18+
# Database & sqlalchemy.
19+
DB_USERNAME = 'username'
20+
DB_PASSWORD = 'password'
21+
DB_SERVER = 'localhost'
22+
DB_NAME = 'dbname'
23+
SQLALCHEMY_DATABASE_URI = 'mysql://{}:{}@{}/{}'.format(
24+
DB_USERNAME, DB_PASSWORD, DB_SERVER, DB_NAME)

0 commit comments

Comments
 (0)