Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- from flask import Flask
- from flask import request
- import config
- import requests
- import time
- app = Flask(__name__)
- i = 0
- def post_to_clojure():
- try:
- r = requests.post(config.uri)
- print r.raw
- except (RuntimeError, TypeError, NameError):
- print "Error while query request"
- @app.route('/start-timer', methods=['GET'])
- def start_timer():
- period = int(float(request.args.get('period')))
- global i
- i = 1
- while i == 1:
- post_to_clojure()
- time.sleep(period)
- @app.route('/stop-timer', methods=['GET'])
- def stop_timer():
- global i
- i = 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement