Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
303 changes: 303 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,303 @@

# Created by https://www.toptal.com/developers/gitignore/api/python,flask,git,macos,windows,venv,visualstudiocode
# Edit at https://www.toptal.com/developers/gitignore?templates=python,flask,git,macos,windows,venv,visualstudiocode

### Flask ###
instance/*
!instance/.gitignore
.webassets-cache

### Flask.Python Stack ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
pytestdebug.log

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/
doc/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
pythonenv*

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# profiling data
.prof

### Git ###
# Created by git for backups. To disable backups in Git:
# $ git config --global mergetool.keepBackup false
*.orig

# Created by git when using merge tools for conflicts
*.BACKUP.*
*.BASE.*
*.LOCAL.*
*.REMOTE.*
*_BACKUP_*.txt
*_BASE_*.txt
*_LOCAL_*.txt
*_REMOTE_*.txt

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### Python ###
# Byte-compiled / optimized / DLL files

# C extensions

# Distribution / packaging

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.

# Installer logs

# Unit test / coverage reports

# Translations

# Django stuff:

# Flask stuff:

# Scrapy stuff:

# Sphinx documentation

# PyBuilder

# Jupyter Notebook

# IPython

# pyenv

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.

# PEP 582; used by e.g. github.com/David-OConnor/pyflow

# Celery stuff

# SageMath parsed files

# Environments

# Spyder project settings

# Rope project settings

# mkdocs documentation

# mypy

# Pyre type checker

# pytype static type analyzer

# profiling data

### venv ###
# Virtualenv
# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
[Bb]in
[Ii]nclude
[Ll]ib
[Ll]ib64
[Ll]ocal
[Ss]cripts
pyvenv.cfg
pip-selfcheck.json

### VisualStudioCode ###
.vscode/*
!.vscode/tasks.json
!.vscode/launch.json
*.code-workspace

### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide

### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

# End of https://www.toptal.com/developers/gitignore/api/python,flask,git,macos,windows,venv,visualstudiocode
12 changes: 7 additions & 5 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,29 @@
app = Flask(__name__)

# url 라우터


@app.route('/')
def index():
now = date.today() # 20200701
now = date.today() # 20200701
now_str = now.strftime("%Y%m%d")
print(now_str)

# 오늘날짜로 요청해
data = corona_data.get_corona_data(now_str,now_str)
data = corona_data.get_corona_data(now_str, now_str)
print(data)
# 없으면 어제 날짜로 요청해라
if not data :
if not data:
yesterday = now - timedelta(days=1)
yesterday_str = yesterday.strftime("%Y%m%d")
print(yesterday_str)

data = corona_data.get_corona_data(yesterday_str,yesterday_str)
data = corona_data.get_corona_data(yesterday_str, yesterday_str)
print(data)


return render_template('index.html', data=data[1:])


# 메인 영역
if __name__ == "__main__":
app.run(debug=True)
18 changes: 10 additions & 8 deletions corona_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
import json
from pprint import pprint

def get_corona_data(startCreateDt, endCreateDt):

def get_corona_data(start_created_at, end_created_at):
url = "http://openapi.data.go.kr/openapi/service/rest/Covid19/getCovid19SidoInfStateJson"
params = {
'serviceKey':'3orEATyZglGF61/gMb9YFa9bNrX72kHX/fxAq+bR17uawigH5YY8v5sr6cNNN6X/cLBtXzPIZN7M7lmwcfH7GQ==',
'pageNo':'1',
'numOfRows':10,
'startCreateDt': startCreateDt , # '20200701',
'endCreateDt': endCreateDt , # '20200701',
'serviceKey': '3orEATyZglGF61/gMb9YFa9bNrX72kHX/fxAq+bR17uawigH5YY8v5sr6cNNN6X/cLBtXzPIZN7M7lmwcfH7GQ==',
'pageNo': '1',
'numOfRows': 10,
'startCreateDt': start_created_at, # '20200701',
'endCreateDt': end_created_at, # '20200701',
}

res = requests.get(url, params=params)
Expand All @@ -33,7 +34,7 @@ def get_corona_data(startCreateDt, endCreateDt):
# totalCount로 제대로 데이터가 가져와졌는지 확인하기
totalCount = dict_data['response']['body']['totalCount']
# print(totalCount)
if totalCount == "0" :
if totalCount == "0":
return False

# 지역 정보를 담은 리스트
Expand All @@ -43,6 +44,7 @@ def get_corona_data(startCreateDt, endCreateDt):

return area_data


if __name__ == "__main__":
data = get_corona_data('20200630','20200630')
data = get_corona_data('20200630', '20200630')
print(data)