部分修改集体上传
This commit is contained in:
14
.gitignore
vendored
14
.gitignore
vendored
@@ -1,15 +1,21 @@
|
|||||||
|
# python/cache
|
||||||
**/__pycache__
|
**/__pycache__
|
||||||
|
**/venv/*
|
||||||
|
**/.venv/*
|
||||||
|
|
||||||
|
# databases
|
||||||
**/*.db
|
**/*.db
|
||||||
**/*.sql
|
**/*.sql
|
||||||
**/*.db.back
|
**/*.db.back
|
||||||
**/venv/*
|
|
||||||
**/.venv/*
|
|
||||||
databases/*
|
databases/*
|
||||||
|
|
||||||
|
# flask folder
|
||||||
mirrors/*
|
mirrors/*
|
||||||
blueprint/kami_views.py
|
blueprint/kami_views.py
|
||||||
|
blueprint/massage_views.py
|
||||||
templates/kami/*
|
templates/kami/*
|
||||||
|
templates/message/*
|
||||||
static/upload/*
|
static/upload/*
|
||||||
static/counter.txt
|
static/counter.txt
|
||||||
static/message/*
|
static/message/*
|
||||||
templates/message/*
|
static/test/*
|
||||||
blueprint/massage_views.py
|
|
||||||
41
api/api.py
Normal file
41
api/api.py
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
from flask import Blueprint
|
||||||
|
import json
|
||||||
|
import sqlite3
|
||||||
|
|
||||||
|
api_api = Blueprint('/api/', __name__)
|
||||||
|
json_title = {'Content-Type': 'application/json'} # 设定json的类型
|
||||||
|
|
||||||
|
# 引入数据库
|
||||||
|
def get_owp_db_conn():
|
||||||
|
conn = sqlite3.connect('/var/open-ww3-project-ww3-tw/databases/sqlite/owp.db')
|
||||||
|
conn.row_factory = sqlite3.Row
|
||||||
|
return conn
|
||||||
|
|
||||||
|
|
||||||
|
# 获取日志内容
|
||||||
|
@api_api.get("/get/logs/")
|
||||||
|
def get_logs():
|
||||||
|
# 获取并查询数据库日志内容
|
||||||
|
conn = get_owp_db_conn()
|
||||||
|
sql_logs = "SELECT * FROM logs;"
|
||||||
|
logs = conn.execute(sql_logs).fetchall()
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
data_logs = [
|
||||||
|
dict(row) for row in logs
|
||||||
|
]
|
||||||
|
return (json.dumps(data_logs, ensure_ascii=False), json_title)
|
||||||
|
|
||||||
|
|
||||||
|
@api_api.get("/get/posts/")
|
||||||
|
def get_posts():
|
||||||
|
# 获取并查询数据库日志内容
|
||||||
|
conn = get_owp_db_conn()
|
||||||
|
sql_posts = "SELECT * FROM posts WHERE status=1;"
|
||||||
|
posts = conn.execute(sql_posts).fetchall()
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
data_posts = [
|
||||||
|
dict(row) for row in posts
|
||||||
|
]
|
||||||
|
return (json.dumps(data_posts, ensure_ascii=False), json_title)
|
||||||
14
api/docs.py
Normal file
14
api/docs.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
from flask import Blueprint
|
||||||
|
|
||||||
|
docs_api = Blueprint('/api/docs', __name__)
|
||||||
|
|
||||||
|
@docs_api.get("/")
|
||||||
|
def home():
|
||||||
|
return """
|
||||||
|
<br><br><h1>其实我最开始是想用fastapi的.....</h1>.....
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
查询日志
|
||||||
|
<br>
|
||||||
|
<a href="https://ww3.tw/api/s/get/logs/">https://ww3.tw/api/s/get/logs/</a>
|
||||||
|
"""
|
||||||
13
main.py
13
main.py
@@ -1,12 +1,16 @@
|
|||||||
from flask import Flask, render_template, redirect, url_for, send_from_directory, make_response, g
|
from flask import Flask, render_template, redirect, url_for, send_from_directory, make_response, g
|
||||||
|
import os
|
||||||
|
import sqlite3
|
||||||
|
import secrets
|
||||||
|
# 引入蓝图
|
||||||
from blueprint.blog_views import blog_bp
|
from blueprint.blog_views import blog_bp
|
||||||
from blueprint.study_views import study_bp
|
from blueprint.study_views import study_bp
|
||||||
from flask_autoindex import AutoIndex
|
from flask_autoindex import AutoIndex
|
||||||
from blueprint.kami_views import kami_bp
|
from blueprint.kami_views import kami_bp
|
||||||
from blueprint.index_views import index_bp
|
from blueprint.index_views import index_bp
|
||||||
import os
|
# 引入api
|
||||||
import sqlite3
|
from api.docs import docs_api
|
||||||
import secrets
|
from api.api import api_api
|
||||||
|
|
||||||
def get_owp_db_conn():
|
def get_owp_db_conn():
|
||||||
conn = sqlite3.connect('/var/open-ww3-project-ww3-tw/databases/sqlite/owp.db')
|
conn = sqlite3.connect('/var/open-ww3-project-ww3-tw/databases/sqlite/owp.db')
|
||||||
@@ -28,6 +32,9 @@ app.register_blueprint(study_bp, url_prefix='/study')
|
|||||||
app.register_blueprint(kami_bp, url_prefix='/kami')
|
app.register_blueprint(kami_bp, url_prefix='/kami')
|
||||||
app.register_blueprint(index_bp, url_prefix='/')
|
app.register_blueprint(index_bp, url_prefix='/')
|
||||||
|
|
||||||
|
# 注册api
|
||||||
|
app.register_blueprint(docs_api, url_prefix='/api/docs')
|
||||||
|
app.register_blueprint(api_api, url_prefix='/api/s/')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
{% for logs in logs %}
|
{% for logs in logs %}
|
||||||
<tr>
|
<tr>
|
||||||
<td id="td_logs">
|
<td id="td_logs">
|
||||||
<a style='font-size: 18px;'>
|
<a style='font-size: 16.7px;'>
|
||||||
{{ logs['date'].replace('.', '-') }}
|
{{ logs['date'].replace('.', '-') }}
|
||||||
</a>
|
</a>
|
||||||
<br>
|
<br>
|
||||||
|
|||||||
Reference in New Issue
Block a user