Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def __init__(self, facebook_auth_filename=SECRETS_FILENAME):
self.authed = False
self.profiles = None
self.friends = set()



def _load_fb_auth(self):
Expand Down
46 changes: 38 additions & 8 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,48 @@


from flask import Flask, render_template
from flask import Flask, render_template, request, g

import api

app = Flask('tinder-detective')

stalker = api.NSASimulator()

@app.route('/')
def index():
profiles = stalker.get_profiles()
return render_template("main.html", profiles=profiles)


stalker = getattr(g, 'stalker', None)

if stalker is None:
try:
stalker = api.NSASimulator()
except api.AuthenticationError:
return render_template("create_secrets.html")

g.stalker = stalker

error = None
profiles = None
try:
profiles = stalker.get_profiles()
except api.AuthenticationError:
print("Auth error")
error = "There was a problem with authentication"
return render_template("profiles.html", profiles=profiles, error=error)


@app.route('/create_secret', methods=['POST'])
def create_secret():
data = request.form

user_id = data['user_id']
user_secret = data['user_secret']

with open('SECRETS.json', 'w') as f:
f.write("{\n")
f.write(" \"facebook_id\": \"" + user_id + "\",\n")
f.write(" \"facebook_token\": \"" + user_secret + "\"")
f.write("\n")
f.write("}")

return "Successfully wrote to file, please reload the main page"

if __name__ == '__main__':
app.run(debug=True)
app.run(debug=False, port=8080)
27 changes: 27 additions & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">

<link rel="stylesheet" href="https://cdn.rawgit.com/twbs/bootstrap/v4-dev/dist/css/bootstrap.css" crossorigin="anonymous">

<link rel="stylesheet" href="../static/main.css">
</head>
<body>
<div class="container">
<section class="header">
<h1 class="title">Tinder detective I guess</h1>

<p class="slogan"><a class="slogan" href="http://blog.gotinder.com/introducing-tinder-social/">"It's important to note Tinder's not a secret considering 70% of users download Tinder because their friends recommend it."</a></p>
</section>
</div>

{% block content %}

{% endblock %}


<script src="https://cdn.rawgit.com/twbs/bootstrap/v4-dev/dist/js/bootstrap.js" crossorigin="anonymous"></script>
</body>

</html>
23 changes: 23 additions & 0 deletions templates/create_secrets.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{% extends 'base.html' %}

{% block content %}

<div class="container">
<h3>Please create the SECRETS.json file</h3>

<form action='/create_secret' method='POST'>

Facebook user id:<br>
<input type="text" name="user_id" />

<br><br>
Facebook Tinder secret:<br>
<input type="text" name="user_secret" />
<br>
<input type="submit" value="Create SECRETS file"/>


</form>

</div>
{% endblock %}
29 changes: 10 additions & 19 deletions templates/main.html → templates/profiles.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
{% extends 'base.html' %}

<link rel="stylesheet" href="https://cdn.rawgit.com/twbs/bootstrap/v4-dev/dist/css/bootstrap.css" crossorigin="anonymous">
{% block content %}
<section class="container">

<link rel="stylesheet" href="../static/main.css">
</head>
<body>
<div class="container">
<section class="header">
<h1 class="title">Tinder detective I guess</h1>
{% if error %}

<h3>{{ error }}</h3>

<p class="slogan"><a class="slogan" href="http://blog.gotinder.com/introducing-tinder-social/">"It's important to note Tinder's not a secret considering 70% of users download Tinder because their friends recommend it."</a></p>
</section>
</div>
{% endif %}

<section class="container">
{% if profiles %}
{% for profile in profiles %}
<section class="profile">
<section class="photos container">
Expand Down Expand Up @@ -57,10 +50,8 @@ <h3>{{ profile.name }}</h3>

</section>
{% endfor %}
{% endif %}
</section>

{% endblock %}

<script src="https://cdn.rawgit.com/twbs/bootstrap/v4-dev/dist/js/bootstrap.js" crossorigin="anonymous"></script>
</body>

</html>