Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from flask import Flask,render_template,jsonify
- import time
- import pymysql.cursors
- connection = pymysql.connect(host='localhost',
- user='REMOVED',
- password='REMOVED',
- db='REMOVED',
- charset='utf8mb4',
- cursorclass=pymysql.cursors.DictCursor)
- app = Flask(__name__)
- @app.route('/')
- def homepage():
- return render_template('index.html')
- @app.route('/api/recent/<time>')
- def api(time):
- with connection.cursor() as cursor:
- try:
- time = float(time)
- sql = "SELECT * FROM `chat` WHERE `response` IS NOT NULL AND `unix`> %s ORDER BY `unix` DESC LIMIT 25"
- cursor.execute(sql,(time))
- result = cursor.fetchall()
- except Exception as e:
- return 'What are you trying to do good sir?'
- return jsonify(result)
- if __name__ == "__main__":
- app.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement