Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. path = 'foo'
  2. @app.route('/<path:path>', methods=['POST'])
  3. def index(path=None):
  4. # do some stuff...
  5. return flask.render_template('index.html', path=path)
  6.  
  7. from flask import Flask, render_template
  8.  
  9. app = Flask(__name__)
  10.  
  11. @app.route('/')
  12. def index():
  13. return render_template('index.html')
  14.  
  15. @app.route('/<word>', defaults={'word': 'bird'})
  16. def word_up(word):
  17. return render_template('whatstheword.html', word=word)
  18.  
  19. @app.route('/files/<path:path>')
  20. def serve_file(path):
  21. return send_from_directory(app.config['UPLOAD_DIR'], path, as_attachment=True)
  22.  
  23. if __name__ == '__main__':
  24. app.debug = True
  25. app.run(port=9017)
  26.  
  27. def index(path=None):
  28. return render_template('index.html', path=path)
  29.  
  30. path = '/foo'
  31. app.add_url_rule(path, 'index', index)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement