Skip to content

Instantly share code, notes, and snippets.

View simonjcarr's full-sized avatar

Simon Carr simonjcarr

  • Gravity Software
  • Preston, Lancashire
View GitHub Profile
import tweepy
from dotenv import load_dotenv
import os
from websocket import create_connection
import json
load_dotenv()
ws = create_connection(os.environ["WEBSOCKET_SERVER_URL"])
auth = tweepy.OAuthHandler(os.environ["TWITTER_API_KEY"], os.environ["TWITTER_API_SECRET_KEY"])
FROM python:3
Add twitter_client.py /
Add requirements.txt /
RUN pip install -r /requirements.txt
CMD [ "python", "./twitter_client.py" ]
<template>
<div>
<div class="text-2xl text-blue-400 mb-5">Realtime Dev Tweets</div>
<div
v-for="tweet in tweets"
:key="tweet.id"
class="border-2 border-blue-400 p-1 mb-4 shadow rounded"
>
<div class="flex mb-2">
<div class="mr-2">
<template>
<div class="bg-gray-300 flex flex-col h-screen">
<Header />
<div class="p-8 w-3/4 mx-auto bg-white flex-1">
<Tweets />
</div>
</div>
</template>
<script>
<template>
<div></div>
</template>
<script>
export default {
name: "Tweets"
};
</script>
<template>
<div class="bg-black h-32 p-8 shadow">
<div class="text-white text-3xl font-bold">Dev Tweets</div>
</div>
</template>
import tweepy
from dotenv import load_dotenv
import os
from websocket import create_connection
import json
load_dotenv()
ws = create_connection("ws://localhost:8088")
auth = tweepy.OAuthHandler(os.getenv("API_KEY"), os.getenv("API_SECRET_KEY"))
const WebSocket = require('ws')
const wss = new WebSocket.Server({ port: 8088 })
wss.broadcast = function broadcast(data) {
wss.clients.forEach((client) => {
client.send(data)
})
}
import tweepy
from dotenv import load_dotenv
import os
load_dotenv()
auth = tweepy.OAuthHandler(os.getenv("API_KEY"), os.getenv("API_SECRET_KEY"))
auth.set_access_token(os.getenv("ACCESS_TOKEN"),
os.getenv("ACCESS_TOKEN_SECRET"))
api = tweepy.API(auth)
API_KEY="<your twitter api key>"
API_SECRET_KEY="<your twitter api secret key>"
ACCESS_TOKEN="<your twitter access token>"
ACCESS_TOKEN_SECRET="<your twitter access token secret>"