From c58ea1a093bab13d3ab4d4d2a17af0c569fdf779 Mon Sep 17 00:00:00 2001 From: MarkusJoe Date: Sat, 26 Mar 2022 09:07:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/__init__.py | 15 +++++++++++++++ app/utils/__init__.py | 16 ---------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 6df1310..ebe2384 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -6,6 +6,8 @@ # @File Name: __init__.py +import os +import requests from flask import Flask from .main import main from .db.db import SQLite @@ -24,3 +26,16 @@ def create_app(): app.config.from_object(Config) return app + + +def download(): + res = requests.get('http://resource-base.herokuapp.com/download/data.db') + with open('./app/db/data.db', 'wb') as fp: + fp.write(res.content) + + +if __name__ != '__main__': + if not os.path.exists('./app/db/data.db'): + print('数据库文件未找到, 正在下载中') + download() + print('下载完成') diff --git a/app/utils/__init__.py b/app/utils/__init__.py index 17bae59..46fe9e0 100644 --- a/app/utils/__init__.py +++ b/app/utils/__init__.py @@ -5,19 +5,3 @@ # @Create Time: 2022/3/25 # @File Name: __init__.py.py - -import os -import requests - - -def download(): - res = requests.get('http://resource-base.herokuapp.com/download/data.db') - with open('./app/db/data.db', 'wb') as fp: - fp.write(res.content) - - -if __name__ != '__main__': - if not os.path.exists('./app/db/data.db'): - print('数据库文件未找到, 正在下载中') - download() - print('下载完成')