From cbf311ba6ab01f676b91623f6061de16e5ee6f40 Mon Sep 17 00:00:00 2001 From: MarkusJoe Date: Tue, 5 Apr 2022 17:56:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=B8=80=E4=BA=9B=E7=BB=86?= =?UTF-8?q?=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/__init__.py | 26 +------------------------- app/config.py | 31 +++++++++++++++++++++++++++++++ app/main/views.py | 2 +- app/static/index.css | 6 ++++++ app/templates/index.html | 21 +++++++-------------- app/tests/test_db.py | 11 ----------- 6 files changed, 46 insertions(+), 51 deletions(-) create mode 100644 app/config.py create mode 100644 app/static/index.css delete mode 100644 app/tests/test_db.py diff --git a/app/__init__.py b/app/__init__.py index b94071d..648be50 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -8,31 +8,7 @@ from flask import Flask from .main import main - - -class Config: - JSON_SORT_KEYS = False - JSON_AS_ASCII = False - - @staticmethod - def init_app(app): - pass - - -class DevelopmentConfig(Config): - DEBUG = True - - -class ProductionConfig(Config): - DEBUG = False - - -config = { - 'development': DevelopmentConfig, - 'production': ProductionConfig, - - 'default': ProductionConfig -} +from app.config import config def create_app(config_name): diff --git a/app/config.py b/app/config.py new file mode 100644 index 0000000..578407d --- /dev/null +++ b/app/config.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 +# -- coding:utf-8 -- +# @Author: markushammered@gmail.com +# @Development Tool: PyCharm +# @Create Time: 2022/4/5 +# @File Name: config.py + + +class Config: + JSON_SORT_KEYS = False + JSON_AS_ASCII = False + + @staticmethod + def init_app(app): + pass + + +class DevelopmentConfig(Config): + DEBUG = True + + +class ProductionConfig(Config): + DEBUG = False + + +config = { + 'development': DevelopmentConfig, + 'production': ProductionConfig, + + 'default': ProductionConfig +} diff --git a/app/main/views.py b/app/main/views.py index 013b73a..bc28b67 100644 --- a/app/main/views.py +++ b/app/main/views.py @@ -26,8 +26,8 @@ def index(): return render_template('index.html', remote_address=request.remote_addr) -@main.route('/api/v1/', methods=['GET', 'POST']) @main.route('/count/', methods=['GET', 'POST']) +@main.route('/api/v1/', methods=['GET', 'POST']) def api_v1(name: str): length = request.args.get('length', type=int) theme = request.args.get('theme', type=str) diff --git a/app/static/index.css b/app/static/index.css new file mode 100644 index 0000000..5bed60f --- /dev/null +++ b/app/static/index.css @@ -0,0 +1,6 @@ +.intro{ + text-align: center; +} +a { + color: green; +} \ No newline at end of file diff --git a/app/templates/index.html b/app/templates/index.html index b20a952..fe10d99 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -4,30 +4,23 @@ Request Counter | {{ remote_address }} - +
-
+
看到这句话就说明程序正常运行啦!! 查看文档
-
+
服务端使用Flask开发没有使用异步编程
-
- 快速查看当前示例试用例 + -
+ -
+
注: 调用支持POST 和 GET 方法请求
diff --git a/app/tests/test_db.py b/app/tests/test_db.py deleted file mode 100644 index 307cd00..0000000 --- a/app/tests/test_db.py +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env python3 -# -- coding:utf-8 -- -# @Author: markushammered@gmail.com -# @Development Tool: PyCharm -# @Create Time: 2022/3/27 -# @File Name: test_db.py - - -from app.db.db import SQLite - -db = SQLite()