Posts

Showing posts with the label Flask

Localization of Dates and Times with Flask-Moment

Image
Previous post:  Get started with Python Flask Framework on IBM Bluemix Flask-Moment is an extension for Flask applications that integrates  moment.js into Jinja2 templates. Flask-Moment is installed with pip For locally: $ pip install flask-moment For Bluemix: In  requirements.txt  add: Flask-moment==0.5.1 In  hello.py : Initialize Flask-Moment from flask_moment import Moment moment= Moment (app) Add  moment.js  into base template base.html In  templates/base.html : Import  moment.js  library {% block scripts %} {{ super() }} {{ moment.include_moment() }} {% endblock %} To work with timestamps Flask-Moment makes a moment class available to templates. In hello.py passes a variable called current_time to the template for rendering. In  hello.py : Add a datetime variable. from datetime import datetime @app.route('/') def index () : return render_template( 'index.html' , current_time=datetim...

Get started with Python Flask Framework on IBM Bluemix

Image
Get started with Python  Flask  Framework on IBM Bluemix This work is based on  Getting started with Python on Bluemix Tutorial The tutorial will develop a Python web application based on Flask framework and deploy the app on  IBM Bluemix . The app shows up a basic form which users can type their names. When hit enter the name will be added to database and can be accessed at  http://base_url/api/visitors 1. Requirement Git Cf Python 2. Clone example code and run locally git clone http s: //github. com /IBM-Bluemix/ get -started- python cd get -started- python Rename your app Open up, manifest.yml similar like: applications : - name : Lecheebot random-route : true memory : 128 M Run your app locally Ensure that you have installed  pip  in your PC. If not, follow this post:  pip and setuptool on windows now, you can run your app locally by typing the command: pip install -r requirements....