Skip to content

Commit eebbc7c

Browse files
committed
first
0 parents  commit eebbc7c

File tree

2,113 files changed

+390556
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,113 files changed

+390556
-0
lines changed

.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export APP_SETTINGS="config.DevelopmentConfig"
2+
export DATABASE_URL="postgresql:///pycrud"

Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: gunicorn app:app

__pycache__/app.cpython-36.pyc

2.13 KB
Binary file not shown.

__pycache__/config.cpython-36.pyc

1.12 KB
Binary file not shown.

__pycache__/models.cpython-36.pyc

948 Bytes
Binary file not shown.

app.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import os
2+
from flask import Flask, request, jsonify, render_template
3+
from flask_sqlalchemy import SQLAlchemy
4+
5+
6+
7+
app = Flask(__name__)
8+
9+
10+
app.config.from_object(os.environ['APP_SETTINGS'])
11+
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
12+
db = SQLAlchemy(app)
13+
14+
from models import Book
15+
@app.route("/")
16+
def hello():
17+
return "hello world"
18+
19+
@app.route("/add")
20+
def add_book():
21+
name = request.args.get('name')
22+
author = request.args.get('author')
23+
published = request.args.get('published')
24+
try:
25+
book = Book(
26+
name = name,
27+
author = author,
28+
published = published
29+
)
30+
db.session.add(book)
31+
db.session.commit()
32+
return "Book added, bookId = {}".format(book.id)
33+
except Exception as e:
34+
return str(e)
35+
36+
@app.route("/add/form",methods=['GET','POST'])
37+
def add_book_form():
38+
if request.method == 'POST':
39+
name = request.args.get('name')
40+
author = request.args.get('author')
41+
published = request.args.get('published')
42+
try:
43+
book = Book(
44+
name = name,
45+
author = author,
46+
published = published
47+
)
48+
db.session.add(book)
49+
db.session.commit()
50+
return "Book added, bookId = {}".format(book.id)
51+
except Exception as e:
52+
return str(e)
53+
return render_template("getdata.html")
54+
55+
@app.route("/getAllBooks")
56+
def get_all_book():
57+
try:
58+
books = Book.query.all()
59+
return jsonify([i.serialize() for i in books])
60+
except Exception as e:
61+
return str(e)
62+
63+
@app.route("/get/<ids>")
64+
def get_by_id():
65+
try:
66+
book.Book.query.filter_by(id = ids).first()
67+
return jsnoify(book.serialize)
68+
except Exception as e:
69+
return str(e)
70+
71+
if __name__ == '__main__':
72+
app.run()

config.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import os
2+
basedir = os.path.abspath(os.path.dirname(__file__))
3+
4+
class Config(object):
5+
DEBUG = False
6+
TESTING = False
7+
CSRF_ENABLED = True
8+
SECRET_KEY = 'this-really-needs-to-be-changed'
9+
SQLALCHEMY_DATABASE_URI = os.environ['DATABASE_URL']
10+
11+
12+
class ProductionConfig(Config):
13+
DEBUG = False
14+
15+
16+
class StagingConfig(Config):
17+
DEVELOPMENT = True
18+
DEBUG = True
19+
20+
21+
class DevelopmentConfig(Config):
22+
DEVELOPMENT = True
23+
DEBUG = True
24+
25+
26+
class TestingConfig(Config):
27+
TESTING = True

env/bin/activate

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# This file must be used with "source bin/activate" *from bash*
2+
# you cannot run it directly
3+
4+
deactivate () {
5+
unset -f pydoc >/dev/null 2>&1
6+
7+
# reset old environment variables
8+
# ! [ -z ${VAR+_} ] returns true if VAR is declared at all
9+
if ! [ -z "${_OLD_VIRTUAL_PATH+_}" ] ; then
10+
PATH="$_OLD_VIRTUAL_PATH"
11+
export PATH
12+
unset _OLD_VIRTUAL_PATH
13+
fi
14+
if ! [ -z "${_OLD_VIRTUAL_PYTHONHOME+_}" ] ; then
15+
PYTHONHOME="$_OLD_VIRTUAL_PYTHONHOME"
16+
export PYTHONHOME
17+
unset _OLD_VIRTUAL_PYTHONHOME
18+
fi
19+
20+
# This should detect bash and zsh, which have a hash command that must
21+
# be called to get it to forget past commands. Without forgetting
22+
# past commands the $PATH changes we made may not be respected
23+
if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ] ; then
24+
hash -r 2>/dev/null
25+
fi
26+
27+
if ! [ -z "${_OLD_VIRTUAL_PS1+_}" ] ; then
28+
PS1="$_OLD_VIRTUAL_PS1"
29+
export PS1
30+
unset _OLD_VIRTUAL_PS1
31+
fi
32+
33+
unset VIRTUAL_ENV
34+
if [ ! "${1-}" = "nondestructive" ] ; then
35+
# Self destruct!
36+
unset -f deactivate
37+
fi
38+
}
39+
40+
# unset irrelevant variables
41+
deactivate nondestructive
42+
43+
VIRTUAL_ENV="/home/yuukiren/pythoncrud/env"
44+
export VIRTUAL_ENV
45+
46+
_OLD_VIRTUAL_PATH="$PATH"
47+
PATH="$VIRTUAL_ENV/bin:$PATH"
48+
export PATH
49+
50+
# unset PYTHONHOME if set
51+
if ! [ -z "${PYTHONHOME+_}" ] ; then
52+
_OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME"
53+
unset PYTHONHOME
54+
fi
55+
56+
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" ] ; then
57+
_OLD_VIRTUAL_PS1="${PS1-}"
58+
if [ "x" != x ] ; then
59+
PS1="${PS1-}"
60+
else
61+
PS1="(`basename \"$VIRTUAL_ENV\"`) ${PS1-}"
62+
fi
63+
export PS1
64+
fi
65+
66+
# Make sure to unalias pydoc if it's already there
67+
alias pydoc 2>/dev/null >/dev/null && unalias pydoc || true
68+
69+
pydoc () {
70+
python -m pydoc "$@"
71+
}
72+
73+
# This should detect bash and zsh, which have a hash command that must
74+
# be called to get it to forget past commands. Without forgetting
75+
# past commands the $PATH changes we made may not be respected
76+
if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ] ; then
77+
hash -r 2>/dev/null
78+
fi

env/bin/activate.csh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# This file must be used with "source bin/activate.csh" *from csh*.
2+
# You cannot run it directly.
3+
# Created by Davide Di Blasi <davidedb@gmail.com>.
4+
5+
set newline='\
6+
'
7+
8+
alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH:q" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT:q" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate && unalias pydoc'
9+
10+
# Unset irrelevant variables.
11+
deactivate nondestructive
12+
13+
setenv VIRTUAL_ENV "/home/yuukiren/pythoncrud/env"
14+
15+
set _OLD_VIRTUAL_PATH="$PATH:q"
16+
setenv PATH "$VIRTUAL_ENV:q/bin:$PATH:q"
17+
18+
19+
20+
if ("" != "") then
21+
set env_name = ""
22+
else
23+
set env_name = '('"$VIRTUAL_ENV:t:q"') '
24+
endif
25+
26+
if ( $?VIRTUAL_ENV_DISABLE_PROMPT ) then
27+
if ( $VIRTUAL_ENV_DISABLE_PROMPT == "" ) then
28+
set do_prompt = "1"
29+
else
30+
set do_prompt = "0"
31+
endif
32+
else
33+
set do_prompt = "1"
34+
endif
35+
36+
if ( $do_prompt == "1" ) then
37+
# Could be in a non-interactive environment,
38+
# in which case, $prompt is undefined and we wouldn't
39+
# care about the prompt anyway.
40+
if ( $?prompt ) then
41+
set _OLD_VIRTUAL_PROMPT="$prompt:q"
42+
if ( "$prompt:q" =~ *"$newline:q"* ) then
43+
:
44+
else
45+
set prompt = "$env_name:q$prompt:q"
46+
endif
47+
endif
48+
endif
49+
50+
unset env_name
51+
unset do_prompt
52+
53+
alias pydoc python -m pydoc
54+
55+
rehash

env/bin/activate.fish

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# This file must be used using `source bin/activate.fish` *within a running fish ( http://fishshell.com ) session*.
2+
# Do not run it directly.
3+
4+
function _bashify_path -d "Converts a fish path to something bash can recognize"
5+
set fishy_path $argv
6+
set bashy_path $fishy_path[1]
7+
for path_part in $fishy_path[2..-1]
8+
set bashy_path "$bashy_path:$path_part"
9+
end
10+
echo $bashy_path
11+
end
12+
13+
function _fishify_path -d "Converts a bash path to something fish can recognize"
14+
echo $argv | tr ':' '\n'
15+
end
16+
17+
function deactivate -d 'Exit virtualenv mode and return to the normal environment.'
18+
# reset old environment variables
19+
if test -n "$_OLD_VIRTUAL_PATH"
20+
# https://github.com/fish-shell/fish-shell/issues/436 altered PATH handling
21+
if test (echo $FISH_VERSION | tr "." "\n")[1] -lt 3
22+
set -gx PATH (_fishify_path $_OLD_VIRTUAL_PATH)
23+
else
24+
set -gx PATH $_OLD_VIRTUAL_PATH
25+
end
26+
set -e _OLD_VIRTUAL_PATH
27+
end
28+
29+
if test -n "$_OLD_VIRTUAL_PYTHONHOME"
30+
set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
31+
set -e _OLD_VIRTUAL_PYTHONHOME
32+
end
33+
34+
if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
35+
# Set an empty local `$fish_function_path` to allow the removal of `fish_prompt` using `functions -e`.
36+
set -l fish_function_path
37+
38+
# Erase virtualenv's `fish_prompt` and restore the original.
39+
functions -e fish_prompt
40+
functions -c _old_fish_prompt fish_prompt
41+
functions -e _old_fish_prompt
42+
set -e _OLD_FISH_PROMPT_OVERRIDE
43+
end
44+
45+
set -e VIRTUAL_ENV
46+
47+
if test "$argv[1]" != 'nondestructive'
48+
# Self-destruct!
49+
functions -e pydoc
50+
functions -e deactivate
51+
functions -e _bashify_path
52+
functions -e _fishify_path
53+
end
54+
end
55+
56+
# Unset irrelevant variables.
57+
deactivate nondestructive
58+
59+
set -gx VIRTUAL_ENV "/home/yuukiren/pythoncrud/env"
60+
61+
# https://github.com/fish-shell/fish-shell/issues/436 altered PATH handling
62+
if test (echo $FISH_VERSION | tr "." "\n")[1] -lt 3
63+
set -gx _OLD_VIRTUAL_PATH (_bashify_path $PATH)
64+
else
65+
set -gx _OLD_VIRTUAL_PATH $PATH
66+
end
67+
set -gx PATH "$VIRTUAL_ENV/bin" $PATH
68+
69+
# Unset `$PYTHONHOME` if set.
70+
if set -q PYTHONHOME
71+
set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
72+
set -e PYTHONHOME
73+
end
74+
75+
function pydoc
76+
python -m pydoc $argv
77+
end
78+
79+
if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
80+
# Copy the current `fish_prompt` function as `_old_fish_prompt`.
81+
functions -c fish_prompt _old_fish_prompt
82+
83+
function fish_prompt
84+
# Save the current $status, for fish_prompts that display it.
85+
set -l old_status $status
86+
87+
# Prompt override provided?
88+
# If not, just prepend the environment name.
89+
if test -n ""
90+
printf '%s%s' "" (set_color normal)
91+
else
92+
printf '%s(%s) ' (set_color normal) (basename "$VIRTUAL_ENV")
93+
end
94+
95+
# Restore the original $status
96+
echo "exit $old_status" | source
97+
_old_fish_prompt
98+
end
99+
100+
set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
101+
end

0 commit comments

Comments
 (0)