This repository has been archived by the owner on Apr 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fayette.py
80 lines (62 loc) · 1.91 KB
/
fayette.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import json
import requests
import datetime
from flask import Flask, render_template
app = Flask(__name__)
MEETUP_GROUP_URLNAME = 'FayettePy-Python-Meetup'
MEETUP_API_KEY = '555a61807e631511307615d604e7448'
@app.route("/")
def index():
"""
This is the index view for FayettePy.
It is loaded at "/"
"""
return render_template("index.html")
@app.route("/members")
def members():
# Get members from Meetup's API
member_endpoint = "https://api.meetup.com/2/members/"
params = {
'sign': True,
'key': MEETUP_API_KEY,
'group_urlname': MEETUP_GROUP_URLNAME
}
response = requests.get(member_endpoint, params)
api_members = json.loads(response.content)
members = []
for m in api_members['results']:
members.append({
'name': m.get('name', None),
'photo': m.get('photo', None),
'bio': m.get('bio', None),
})
return render_template('members.html', members=members)
@app.route("/events")
def events():
"""
This is the index view for FayettePy.
It is loaded at "/"
"""
# Get events from Meetup's API
events_endpoint = "https://api.meetup.com/2/events/"
params = {
'sign': True,
'key': MEETUP_API_KEY,
'group_urlname': MEETUP_GROUP_URLNAME
}
response = requests.get(events_endpoint, params)
api_events = json.loads(response.content)
events = []
for e in api_events['results']:
date = datetime.datetime.fromtimestamp(e.get('time', None) / 1000)
events.append({
'name': e.get('name', None),
'url': e.get('event_url', None),
'venue': e.get('venue', None),
'date': date.strftime("%A, %B %d, %Y at %I:%S %p"),
'description': e.get('description', None),
})
return render_template("events.html", events=events)
if __name__ == '__main__':
app.debug = True
app.run()