-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add raw data view and python script for access sql dbs.
- Loading branch information
Showing
13 changed files
with
373 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import pandas as pd | ||
from sqlalchemy import create_engine | ||
engine = create_engine('sqlite:////crime.db') | ||
|
||
|
||
@app.route('/') | ||
def hello_world(): | ||
return 'Hello, World!' | ||
|
||
import json | ||
|
||
@app.route('/data',methods=['POST']) | ||
@cross_origin() | ||
def data(): | ||
if request.method == 'POST': | ||
q = request.form['q'] | ||
format = request.form['format'] | ||
resp = make_response() | ||
|
||
data='' | ||
mime='' | ||
if format=='json': | ||
data = json.dumps(pd.read_sql(q,engine).to_dict(orient='records')) | ||
mime = 'text/json' | ||
|
||
if format=='csv': | ||
data = pd.read_sql(q,engine).to_csv(index=False) | ||
mime = 'text/csv' | ||
|
||
resp.data=data | ||
resp.mimetype=mime | ||
|
||
return resp | ||
else: | ||
return '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
<!DOCTYPE html><html><head><meta name="viewport" content="initial-scale=1,maximum-scale=1, | ||
user-scalable=no"><link rel="stylesheet" href="web.d128e249.css"></head><body> <div id="nc"></div> </body><script src="web.6fb7e690.js"></script></html> | ||
user-scalable=no"><link rel="stylesheet" href="web.416d5ffe.css"></head><body> <div id="nc"></div> </body><script src="web.5b9c68c4.js"></script></html> |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.