コード例 #1
0
ファイル: app.py プロジェクト: jashwanth24/flasktemplate
    if request.method == 'PUT':
        note = str(request.data.get('text', ''))
        notes[key] = note
        mysql_connection = mysql.connection.cursor()
        mysql_connection.execute('''SELECT testRunId FROM testresultparent ORDER BY updatedAt DESC LIMIT 1;''')
        testrunid_data = mysql_connection.fetchall()
        rm_tuple = testrunid_data[0]
        rm = rm_tuple[0]
        testrunid = str(rm)
        getMetrics()
        push_to_gateway(prome, job=testrunid, registry=registry)
        return note_repr(key)

    elif request.method == 'DELETE':
        notes.pop(key, None)
        mysql_connection = mysql.connection.cursor()
        mysql_connection.execute('''SELECT testRunId FROM testresultparent ORDER BY updatedAt DESC LIMIT 1;''')
        testrunid_data = mysql_connection.fetchall()
        rm_tuple = testrunid_data[0]
        rm = rm_tuple[0]
        testrunid = str(rm)
        getMetrics()
        push_to_gateway(prome, job=testrunid, registry=registry)
        return 'Deleted successfully'

    
if __name__ == "__main__":
    start_http_server(8000)
    app.before_request(before_request)
    app.run(host='0.0.0.0', port=5000)
コード例 #2
0
ファイル: app.py プロジェクト: xxdoor/hospital-app
from flask_api import status
from flask_cors import CORS
from flask import request
import hashlib
import flask

from common import readConfig
from common import rest_log
from common import edit_redis
from common import utils
from common import mysqlUtils

app = FlaskAPI(__name__)
CORS(app)
log_kit = rest_log.RestLog()
app.before_request(log_kit.log_request)


def make_response(content, code=status.HTTP_200_OK):
    """
    覆盖原方法,用来打日志,并构造返回内容
    :param content:
    :param code:
    :return:
    """
    response = flask.make_response(content, code)
    log_kit.log_response(flask.request, response)
    return response


@app.route('/')