Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from flask import Flask, jsonify
- app = Flask(__name__)
- @app.route('/log/<int:id>')
- def find_log_record(id):
- with open('log.txt', 'r') as f:
- for line in f:
- rec_id, time, event_type = line.strip('\n').split(' ')
- rec_id = int(rec_id)
- if rec_id == id:
- return jsonify(
- id = rec_id,
- time = time,
- event_type = event_type
- )
- return 'No such record'
- app.run(host='localhost', port=1010)
Advertisement
Add Comment
Please, Sign In to add comment