Skip to content

Commit

Permalink
Update fixes error indentation in models.py file
Browse files Browse the repository at this point in the history
and added troubleshoots for beginners in README.md file
and added pip2 compatible format with
requirements-pip2.txt file
and added gitignore file with basics
and removed useless empty subfolder flask easy template
  • Loading branch information
Systemaker committed Feb 19, 2017
1 parent d2c4c0c commit 4302cea
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 33 deletions.
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Byte-compiled / optimized files
__pycache__/
*.py[cod]

# Database maybe
# *.sqlite

#log file maybe
*.log

# Project specific ignores
*.swp
*.bak

local_config.py
.idea/
.vscode/
1 change: 0 additions & 1 deletion Flask-Easy-Template
Submodule Flask-Easy-Template deleted from 631670
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,43 @@ Creating a bookmark for easier access

Your Feedback is appreciated :)

##### TROUBLESHOOTS FOR BEGINNERS :

- READ FIRST : About Python 2 and 3 compatibility
Some scripts and modules versions required here are written in python 2 and not ready yet for python 3 ,
so it is recommended to download and install both interpreters python 2 and also python 3 (for windows users don't forget to add their folder paths also in your environment variables)
Then when calling python scripts in version 2 or 3 anyway (example with the package manager script PIP), you can run default python command like :
"python -m pip install ..." or "pip install ..."
To call only python 3 scripts choose this instead :
"py -m pip install ..." or "pip3 install ..."


- Error parsing in requirements.txt ?
Run instead this compatible formatted file :
python -m pip install -r requirements-pip2.txt
or convert first your requirements.txt to a python 2 pip2 compatible format with this command :
python -m pip list --format=freeze > requirements.txt


- Error install on Proxytype : SyntaxError like Missing parentheses in call to 'print' ?
the print function requires parentheses in Python 3 but not in Python 2 which means that the extension that you are trying to install is not yet compatible with python 3
This is why it is recommended to install python 3 and python 2 by default.
So run instead this compatible command for python 2 extensions (after installing python 2 if not got it yet) :
python -m pip install -r requirements-pip2.txt
or python -m pip install ...


- Error install module Pycrypto : microsoft visual c++ compiler for python 2.7 is required ?
download and install microsoft visual c++ compiler for python 2.7 here : https://www.microsoft.com/en-us/download/details.aspx?id=44266


- Error Tornado module not found ?
it is a problem when installing modules like tornado in a multiple python interpreters environment
So run instead this common command python which precize by default the python 2 version
python -m pip install -r requirements-pip2.txt
or python -m pip install ...
or python run.py


##### License: Apache 2.0

Expand Down
64 changes: 32 additions & 32 deletions application/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,35 @@ def get_id(self, some_id):
return aux


def add_data(self, title, description):
new_record = SampleTable(title=title, description=description)
db.session.add(new_record)
db.session.commit()


def list_all(self, page, LISTINGS_PER_PAGE):
return SampleTable.query.order_by(desc(SampleTable.added_time)).paginate(page, LISTINGS_PER_PAGE, False)


# ------ Delete them if you don't plan to use them ----------

def benchmark_searchspeed(self):
# my very stupid benchmark
records = SampleTable.query.filter(
or_(SampleTable.description.like('%ab%'), SampleTable.description.like('%10%'))).order_by(
desc(SampleTable.added_time)).limit(500)
output = list()
for record in records:
second = SampleTable.query.filter(SampleTable.description.contains(record.title[0:1])).first()
if second:
aux = dict()
aux['id'] = second.id
aux['title'] = second.title
aux['description'] = second.description
aux['added_time'] = second.added_time
output.append(aux)
return output


def __str__(self):
return '<SampleTable %r, %s>' % (self.id, self.title)
def add_data(self, title, description):
new_record = SampleTable(title=title, description=description)
db.session.add(new_record)
db.session.commit()


def list_all(self, page, LISTINGS_PER_PAGE):
return SampleTable.query.order_by(desc(SampleTable.added_time)).paginate(page, LISTINGS_PER_PAGE, False)


# ------ Delete them if you don't plan to use them ----------

def benchmark_searchspeed(self):
# my very stupid benchmark
records = SampleTable.query.filter(
or_(SampleTable.description.like('%ab%'), SampleTable.description.like('%10%'))).order_by(
desc(SampleTable.added_time)).limit(500)
output = list()
for record in records:
second = SampleTable.query.filter(SampleTable.description.contains(record.title[0:1])).first()
if second:
aux = dict()
aux['id'] = second.id
aux['title'] = second.title
aux['description'] = second.description
aux['added_time'] = second.added_time
output.append(aux)
return output


def __str__(self):
return '<SampleTable %r, %s>' % (self.id, self.title)
Binary file added requirements-pip2.txt
Binary file not shown.

0 comments on commit 4302cea

Please sign in to comment.