mirror of
https://git.wownero.com/wownero/YellWOWPages.git
synced 2024-08-15 01:03:25 +00:00
Rewrite to Quart web-framework, refactor code.
This commit is contained in:
parent
6b300fd304
commit
67f4c34604
39 changed files with 656 additions and 980 deletions
25
yellow/api.py
Normal file
25
yellow/api.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
from quart import render_template, request, redirect, url_for, jsonify, Blueprint, abort, flash, send_from_directory, current_app
|
||||
|
||||
import settings
|
||||
from yellow.models import User
|
||||
|
||||
bp_api = Blueprint('bp_api', __name__, url_prefix='/api')
|
||||
|
||||
|
||||
@bp_api.get("/")
|
||||
async def api_root():
|
||||
return await render_template('api.html')
|
||||
|
||||
|
||||
@bp_api.get('/user/')
|
||||
async def api_all():
|
||||
return jsonify([u.to_json(ignore_key='id') for u in User.select()])
|
||||
|
||||
|
||||
@bp_api.get('/user/<path:needle>')
|
||||
async def api_search(needle: str):
|
||||
try:
|
||||
return jsonify([u.to_json(ignore_key='id') for u in await User.search(needle)])
|
||||
except Exception as ex:
|
||||
current_app.logger.error(ex)
|
||||
return jsonify([])
|
Loading…
Add table
Add a link
Reference in a new issue