├── requirements.txt ├── run.sh ├── .bowerrc ├── .gitignore ├── README.md ├── project ├── app.py ├── static │ ├── css │ │ └── style.css │ └── scripts │ │ ├── jsx │ │ └── main.js │ │ └── js │ │ └── main.js └── templates │ ├── index.html │ └── hello.html ├── bower.json ├── gulpfile.js └── package.json /requirements.txt: -------------------------------------------------------------------------------- 1 | Flask==0.10.1 2 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | python project/app.py -------------------------------------------------------------------------------- /.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "./project/static/bower_components" 3 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.DS_Store 2 | *.pyc 3 | .git 4 | 5 | env 6 | venv 7 | 8 | node_modules/ 9 | npm-debug.log 10 | bower_components/ 11 | .module-cache -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Be sure to check out the blog posts- 2 | 3 | 1. https://realpython.com/blog/python/the-ultimate-flask-front-end/ 4 | 1. https://realpython.com/blog/python/the-ultimate-flask-front-end-part-2/ -------------------------------------------------------------------------------- /project/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, render_template 2 | 3 | app = Flask(__name__) 4 | 5 | 6 | @app.route('/') 7 | def index(): 8 | return render_template('index.html') 9 | 10 | 11 | @app.route('/hello') 12 | def hello(): 13 | return render_template('hello.html') 14 | 15 | 16 | if __name__ == '__main__': 17 | app.run(debug=True) 18 | -------------------------------------------------------------------------------- /project/static/css/style.css: -------------------------------------------------------------------------------- 1 | /* custom styles */ 2 | 3 | .container { 4 | text-align: center; 5 | padding-top: 50px; 6 | max-width: 300px; 7 | } 8 | 9 | 10 | input { 11 | text-align: center; 12 | border: 5px solid; 13 | padding: 13px 12px; 14 | font-size: 16px; 15 | outline: none; 16 | margin-bottom: 20px; 17 | } 18 | 19 | 20 | ul { 21 | margin-left: 20px; 22 | text-align: left; 23 | } -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ultimate-flask-front-end", 3 | "homepage": "https://github.com/realpython/ultimate-flask-front-end", 4 | "authors": [ 5 | "Michael Herman michael@realpython.com" 6 | ], 7 | "description": "", 8 | "main": "", 9 | "license": "MIT", 10 | "ignore": [ 11 | "**/.*", 12 | "node_modules", 13 | "bower_components", 14 | "test", 15 | "tests" 16 | ], 17 | "dependencies": { 18 | "bootstrap": "^3.3.6", 19 | "react": "^15.1.0" 20 | } 21 | } -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | // requirements 2 | 3 | var gulp = require('gulp'); 4 | var gulpBrowser = require("gulp-browser"); 5 | var reactify = require('reactify'); 6 | var del = require('del'); 7 | var size = require('gulp-size'); 8 | 9 | 10 | // tasks 11 | 12 | gulp.task('transform', function () { 13 | var stream = gulp.src('./project/static/scripts/jsx/*.js') 14 | .pipe(gulpBrowser.browserify({transform: ['reactify']})) 15 | .pipe(gulp.dest('./project/static/scripts/js/')) 16 | .pipe(size()); 17 | return stream; 18 | }); 19 | 20 | gulp.task('del', function () { 21 | return del(['./project/static/scripts/js']); 22 | }); 23 | 24 | gulp.task('default', ['del'], function () { 25 | gulp.start('transform'); 26 | gulp.watch('./project/static/scripts/jsx/*.js', ['transform']); 27 | }); -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ultimate-flask-front-end", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/realpython/ultimate-flask-front-end.git" 12 | }, 13 | "author": "", 14 | "license": "ISC", 15 | "bugs": { 16 | "url": "https://github.com/realpython/ultimate-flask-front-end/issues" 17 | }, 18 | "homepage": "https://github.com/realpython/ultimate-flask-front-end#readme", 19 | "devDependencies": { 20 | "bower": "^1.7.9", 21 | "del": "^2.2.0", 22 | "gulp": "^3.9.1", 23 | "gulp-browser": "^2.1.4", 24 | "gulp-size": "^2.1.0", 25 | "reactify": "^1.1.1" 26 | } 27 | } -------------------------------------------------------------------------------- /project/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |