mirror of
https://github.com/jlengrand/twitterboard.git
synced 2026-03-10 08:51:22 +00:00
Might I be on the right track? Finally ?
This commit is contained in:
29
tests/flask_stop.py
Normal file
29
tests/flask_stop.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import time
|
||||
from multiprocessing import Process
|
||||
from flask import Flask
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
return "Hi there!!!"
|
||||
|
||||
|
||||
def run():
|
||||
app.run()
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.debug = True
|
||||
print "starting process"
|
||||
server = Process(target=run)
|
||||
server.start()
|
||||
|
||||
print "sleeping"
|
||||
time.sleep(5)
|
||||
|
||||
print "ending process"
|
||||
server.terminate()
|
||||
server.join()
|
||||
|
||||
print "bye..."
|
||||
@@ -10,6 +10,12 @@ from datamodel import TrendyHashtag
|
||||
from datamodel import Tweet
|
||||
from datamodel import Member
|
||||
|
||||
from streamer import HashtagLogger
|
||||
|
||||
|
||||
import signal
|
||||
import sys
|
||||
|
||||
|
||||
def connect():
|
||||
"""
|
||||
@@ -58,5 +64,24 @@ def add_hashtag():
|
||||
def index():
|
||||
return render_template('statistics.html')
|
||||
|
||||
|
||||
class Twiderboard():
|
||||
def __init__(self):
|
||||
# registering the signal to stop command line
|
||||
signal.signal(signal.SIGINT, self.stop_handler)
|
||||
|
||||
print "Starting streamer"
|
||||
self.h = HashtagLogger(data.engine_url, oauth=data.oauth)
|
||||
self.h.start()
|
||||
|
||||
app.run()
|
||||
|
||||
def stop_handler(self, signal, frame):
|
||||
print "Stopping Streamer"
|
||||
self.h.stop()
|
||||
print "Stopping Command Line"
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run()
|
||||
Twiderboard()
|
||||
|
||||
10
twiderboard/twiderboard.py
Normal file
10
twiderboard/twiderboard.py
Normal file
@@ -0,0 +1,10 @@
|
||||
"""
|
||||
Top level application that will start the streamer and the API.
|
||||
"""
|
||||
|
||||
from flask_app import app
|
||||
|
||||
class Twiderboard():
|
||||
def __init__(self):
|
||||
app.run()
|
||||
print "coucou"
|
||||
Reference in New Issue
Block a user