Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
website
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jannik Hellenkamp
website
Commits
089259b6
Commit
089259b6
authored
8 years ago
by
Julian Rother
Browse files
Options
Downloads
Patches
Plain Diff
Changed configuration to flasks native solution
parent
35b8849e
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
server.py
+6
-6
6 additions, 6 deletions
server.py
with
6 additions
and
6 deletions
server.py
+
6
−
6
View file @
089259b6
...
...
@@ -2,9 +2,10 @@
from
flask
import
Flask
,
render_template
,
g
import
mysql.connector
import
sqlite3
import
config
app
=
Flask
(
__name__
)
config
=
app
.
config
config
.
from_pyfile
(
'
config.py
'
)
# Row wrapper for sqlite
def
dict_factory
(
cursor
,
row
):
...
...
@@ -17,15 +18,15 @@ def dict_factory(cursor, row):
return
d
def
query
(
operation
,
*
params
):
if
config
.
db_engine
==
'
mysql
'
:
if
config
[
'
DB_ENGINE
'
]
==
'
mysql
'
:
if
'
db
'
not
in
g
or
not
g
.
db
.
is_connected
():
g
.
db
=
mysql
.
connector
.
connect
(
user
=
config
.
db_user
,
password
=
config
.
db_passwd
,
host
=
config
.
db_host
,
database
=
config
.
db_db
)
g
.
db
=
mysql
.
connector
.
connect
(
user
=
config
[
'
MYSQL_USER
'
]
,
password
=
config
[
'
MYSQL_PASSWD
'
],
host
=
config
[
'
MYSQL_HOST
'
]
,
database
=
config
[
'
MYSQL_DB
'
]
)
cur
=
g
.
db
.
cursor
(
dictionary
=
True
)
cur
.
execute
(
operation
.
replace
(
'
?
'
,
'
%s
'
),
params
)
return
cur
.
fetchall
()
el
se
:
el
if
config
[
'
DB_ENGINE
'
]
==
'
sqlite
'
:
if
'
db
'
not
in
g
or
not
g
.
db
.
is_connected
():
g
.
db
=
sqlite3
.
connect
(
config
.
db_file
)
g
.
db
=
sqlite3
.
connect
(
config
[
'
SQLITE_DB
'
]
)
g
.
db
.
row_factory
=
dict_factory
cur
=
g
.
db
.
cursor
()
cur
.
execute
(
operation
,
params
)
...
...
@@ -57,5 +58,4 @@ def play():
return
render_template
(
'
play.html
'
,
active_page
=
'
play
'
)
if
__name__
==
'
__main__
'
:
app
.
debug
=
True
app
.
run
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment