コード例 #1
0
def get_tweets():
    tweets = []
    client = twitter_api_client()
    # client = current_app.config["TWITTER_API_CLIENT"]
    # 'extended' to see full tweet
    statuses = client.user_timeline("elonmusk", tweet_mode="extended")
    for ss in statuses:
        tweets.append({"id": ss.id_str, "message": ss.full_text})
    print(tweets)
    return jsonify(tweets)
コード例 #2
0
def create_app():
    app = Flask(__name__)
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    app.config['SQLALCHEMY_DATABASE_URI'] = DATABASE_URL
    app.config['TWITTER_API_CLIENT'] = twitter_api_client()
    db.init_app(app)
    migrate.init_app(app, db)

    app.register_blueprint(routes)
    return app
コード例 #3
0
def user_tweets():
    tweets = []
    client = twitter_api_client()
    handle = dict(request.form)
    statuses = client.user_timeline(handle['username'], tweet_mode="extended")
    for status in statuses:
        tweets.append({
            "created": status.created_at,
            "user": status.user,
            "message": status.full_text
        })
    return render_template("user_timeline.html", tweets=tweets, handle=handle)
コード例 #4
0
def create_app():
    app = Flask(__name__)
    app.config["CUSTOM_VAR"] = 5  # just an example of app config :-D
    #app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///web_app_200.db"
    app.config["SQLALCHEMY_DATABASE_URI"] = DATABASE_URL
    app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
    app.config["TWITTER_API_CLIENT"] = twitter_api_client()

    db.init_app(app)
    migrate.init_app(app, db)

    app.register_blueprint(my_routes)
    #app.register_blueprint(more_routes)

    return app
コード例 #5
0
from flask import Blueprint, jsonify, request, render_template, flash
from sklearn.linear_model import LogisticRegression
import numpy as np

from web_app.models import User, Tweet, db
from web_app.twitter_service import twitter_api_client
from web_app.basilica_service import basilica_connection
#from web_app.classifier import load_model

new_routes = Blueprint("new_routes", __name__)

client = twitter_api_client()
basilica_client = basilica_connection()
#classifier_model = load_model()


@new_routes.route("/")
def index():
    return render_template("homepage.html")


#
# DATABASE STUFF
#


@new_routes.route("/users")
@new_routes.route("/users.json")
def list_users():
    print("LISTING USERS...")
    users = User.query.all()  # returns a list of <class 'alchemy.User'>