Skip to content

Commit a9b10cb

Browse files
committed
Eliminated database lookup (twitter won't let us authorize xauth
authentication)
1 parent 9ddc666 commit a9b10cb

File tree

6 files changed

+54
-48
lines changed

6 files changed

+54
-48
lines changed

CHALLENGE.md

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#Professional Services Engineer Coding Challenge
2+
Coding challenge for candidates working on web services. Basic premise is to write a REST API that talks to Twitter and presents some information from tweets, and a front end app that interacts with API. Should be able to run locally on a laptop for testing and evaluation.
3+
4+
###Skills & Knowledge Being Assessed
5+
+ Software development
6+
+ Python web development
7+
+ REST APIs
8+
+ JavaScript
9+
+ Written communication
10+
11+
##Instructions
12+
Timeframe: ~ 7 day limit, can turn in early when done, can ask for extension
13+
14+
This private GitHub repository (private repo) contains a skeleton Flask project which you will use to implement a basic REST API. The settings.py file in the project contains an Application Token and Secret for making authenticated requests against Twitter's API (see General expectations/notes below for 3rd party library usage).
15+
16+
###Notes About the Code Provided
17+
The Flask application is already configured to read from the settings.py file.
18+
No models, views, or url configurations have been defined.
19+
20+
##Deliverables
21+
###REST API
22+
Create a view that fulfills the following requirements:
23+
####Backend
24+
+ Accept a "twitter_account.id"
25+
+ Use the Application Token and Secret to authenticate with Twitter's API.
26+
+ Fetch the public timeline for the twitter_account.id from Twitter's API
27+
+ Extract the Screen Name, Text, Tweet ID, Date, and Profile Image from each object
28+
+ Transform the date into a Unix Timestamp
29+
+ Render the result as a JSON response
30+
31+
####Front-End
32+
Using the API written in Flask, you’ll create a JavaScript webapp that makes a request for a Twitter user’s timeline and displays the tweets returned. You can use a JavaScript framework (AngularJS, Ember.js, etc.) if you want. The tweets should be rendered in a list view and each message/tweet should display the following items:
33+
+ Avatar image of author
34+
+ Screen name of author
35+
+ Tweet text
36+
+ Reply icon (see below for details)
37+
+ Relative timestamp (e.g. 5 minutes ago, 2 hours ago, 1 week ago)
38+
39+
#####Reply Icon
40+
Each Tweet should contain a dummy reply action. When clicking on the Reply icon, the app should show a prompt that prints the Tweet text, Tweet ID, and the author’s user ID.
41+
42+
#####Markup/Styles
43+
There are no strict requirements for how tweets are rendered.
44+
###General Expectations & Notes
45+
+ Fork the repo into your GitHub account and work against that
46+
+ When the project is completed issue a pull request back to the original repo
47+
+ The URLs and views should be laid out in a RESTful fashion
48+
+ Readable code (e.g., PEP 8)
49+
+ Error handling matters
50+
+ Clean markup and styles are important.
51+
+ Use best practices/conventions
52+
+ Feel free to use any 3rd party libraries (e.g. Python Twitter lib, Python OAuth lib, JavaScript time formatting lib, jQuery, etc)
53+

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Clone the repository and run the challenge app
1111
```
1212
$ git clone [email protected]:lukaszlacinski/challenge.git
1313
$ cd challenge
14-
$ export FLASK_APP=challenge
14+
$ export FLASK_APP=challenge.py
1515
$ flask run
1616
* Serving Flask app "challenge"
1717
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

app.db

-3 KB
Binary file not shown.

challenge.py

-38
Original file line numberDiff line numberDiff line change
@@ -4,51 +4,13 @@
44
55
"""
66

7-
from sqlite3 import dbapi2 as sqlite3
87
from flask import Flask, g
98
app = Flask(__name__)
109

1110

1211
app.config.from_object('settings')
1312

1413

15-
def connect_db():
16-
"""Connects to the specific database."""
17-
rv = sqlite3.connect(app.config['DATABASE'])
18-
rv.row_factory = sqlite3.Row
19-
return rv
20-
21-
22-
def get_db():
23-
"""Opens a new database connection if there is none yet for the
24-
current application context.
25-
"""
26-
if not hasattr(g, app.config['DATABASE']):
27-
g.sqlite_db = connect_db()
28-
return g.sqlite_db
29-
30-
31-
def init_db():
32-
db = get_db()
33-
with app.open_resource('schema.sql', mode='r') as f:
34-
db.cursor().executescript(f.read())
35-
db.commit()
36-
37-
38-
@app.cli.command('initdb')
39-
def initdb_command():
40-
"""Initializes the database"""
41-
init_db()
42-
print 'Initialized the database'
43-
44-
45-
@app.teardown_appcontext
46-
def close_db(error):
47-
"""Closes the database again at the end of the request."""
48-
if hasattr(g, app.config['DATABASE']):
49-
g.sqlite_db.close()
50-
51-
5214
@app.route('/')
5315
def challenge():
5416
return 'Globus Challenge'

schema.sql

-8
This file was deleted.

settings.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
DATABASE='app.db'
21
TWITTER_API_KEY='EgIpXFxHbPmoXyvAc3PbGCcE9'
32
TWITTER_API_SECRET='D0asdg77XAv0g9QT9C6RKR8W0D3UBxPpE0QNGhPy8RBeYcQHKr'

0 commit comments

Comments
 (0)