Browse Source

POSTing should be good, but ..

It's not a full circle yet and it doesn't seem to be anything simpler;
maybe I gotta start from a scratch again
master
sipp11 10 years ago
parent
commit
83965929cd
  1. 24
      auth.py
  2. 3
      flasky.py
  3. 14
      templates/home.html

24
auth.py

@ -12,19 +12,27 @@ def csrf_token_generator(size=40, chars=string.ascii_uppercase + string.digits):
return ''.join(random.choice(chars) for _ in range(size)) return ''.join(random.choice(chars) for _ in range(size))
def generate_auth_token(user, expiration=600): def generate_auth_token(user, expires_in=3000):
s = Serializer(app_secret, expires_in=expiration) s = Serializer(app_secret, expires_in)
return s.dumps({'id': 1}) return s.dumps({'id': 1})
def verify_token(token):
try:
s = Serializer(app_secret)
data = s.loads(token)
return data['id']
except:
return None
def check_basic_auth(user, passwd): def check_basic_auth(user, passwd):
''' if passwd in ('', 'unused') and verify_token(user):
TODO: check token too -- password will be 'unused' return True
''' elif user == app_user or passwd == app_password:
if user != app_user or passwd != app_password:
return False
else:
return True return True
else:
return False
def authenticate(): def authenticate():

3
flasky.py

@ -94,11 +94,10 @@ miscObjHandler = lambda obj: (
@app.route('/') @app.route('/')
@app.route('/flask/')
@crossdomain(origin='*') @crossdomain(origin='*')
def hello_world(): def hello_world():
# return 'This comes from Flask ^_^' # return 'This comes from Flask ^_^'
return render_template('layout.html') return render_template('home.html')
@app.route('/movies/', methods=['GET']) @app.route('/movies/', methods=['GET'])

14
templates/home.html

@ -0,0 +1,14 @@
{% extends "layout.html" %}
{% block body %}
<h2>Links</h2>
<ul>
<li>movies<ul>
<li><a href="movies/nowshowing">nowshowing</a></li>
<li><a href="movies/comingsoon">coming soon</a></li>
<li><a href="movies/older">older</a></li>
</ul></li>
<li><a href="groups">group</a></li>
<li><a href="theaters">theaters</a></li>
<li><a href="showtimes/sf/">showtimes</a></li>
</ul>
{% endblock %}
Loading…
Cancel
Save