Repository: abhiomkar/flask-react
Branch: master
Commit: 503d4dad5c39
Files: 13
Total size: 7.4 KB
Directory structure:
gitextract_u2vxkvbm/
├── .bowerrc
├── .gitignore
├── LICENSE
├── Procfile
├── README.md
├── app/
│ ├── __init__.py
│ ├── static/
│ │ ├── css/
│ │ │ ├── main.css
│ │ │ └── styles.css
│ │ └── jsx/
│ │ ├── components/
│ │ │ └── App.js
│ │ └── main.js
│ └── templates/
│ └── base.html
├── bower.json
└── requirements.txt
================================================
FILE CONTENTS
================================================
================================================
FILE: .bowerrc
================================================
{
"directory": "app/static/libs"
}
================================================
FILE: .gitignore
================================================
app/static/libs/
app/static/js/
node_modules
.DS_Store
.module-cache
Gruntfile.js
package.json
================================================
FILE: LICENSE
================================================
The MIT License (MIT)
Copyright (c) 2014 Abhinay Omkar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: Procfile
================================================
web: gunicorn app:app --log-file=-
================================================
FILE: README.md
================================================
Flask React
===========
Introduction
------------
Boilerplate to create a simple web app with Flask and React. Other fontend libraries included Twitter Bootstrap, jQuery, Lodash, Require.js & Font Awesome.
Demo
----
Deployed on Heroku: [flask-react.herokuapp.com](http://flask-react.herokuapp.com)
Installation
------------
* Install python dependencies
pip install flask requests
* Install required frontend libraries using [bower](http://bower.io/#install-bower).
bower install
* Transform JSX to JS using [React tool](http://facebook.github.io/react/docs/tooling-integration.html#productionizing-precompiled-jsx) for development purpose
jsx --watch app/static/jsx app/static/js
* Run Flask server
python app/main.py
* Start coding! :)
Author
------
Abhinay Omkar <abhiomkar@gmail.com>
License
-------
MIT
TODO
----
- Migrate to ES6. Get rid of deprecated JSX.
- Support server side rendering of React components
- Use webpack & gulp for packaging and building.
- Use PostCSS.
- Add deploy instructions.
================================================
FILE: app/__init__.py
================================================
import requests
import os
import json
from flask import Flask, Response, request, session, g, redirect, url_for, abort, render_template, flash
from urlparse import urljoin
app = Flask(__name__)
@app.route("/")
def index():
return render_template('base.html')
@app.route('/api/<path:path>', methods=['GET'])
def api(path):
clientToken = ''
clientSecret = ''
baseUrl = 'https://suggestqueries.google.com'
accessToken = ''
# Authentication
#
# session.auth = EdgeGridAuth (
# client_token = clientToken,
# client_secret = clientSecret,
# access_token = accessToken
# )
r = requests.get(urljoin(baseUrl, path), params=request.args)
if r.status_code != requests.codes.ok:
return None
return Response(r.content, mimetype='application/json')
if __name__ == "__main__":
app.run(debug=True)
================================================
FILE: app/static/css/main.css
================================================
@import '../libs/bootstrap/dist/css/bootstrap.min.css';
@import '../libs/font-awesome/css/font-awesome.css';
@import 'styles.css';
================================================
FILE: app/static/css/styles.css
================================================
.r-container {
margin: auto;
width: 400px;
margin-top: 200px;
}
.r-container h1 {
font-family: 'Helvetica Nueu', Helvetica, Arial, sans-serif;
font-weight: 300;
font-size: 16px;
color: #3F3F3F;
}
.r-container > input {
width: 100%;
font-size: 15px;
font-weight: 300;
border: 1px solid #cdcdcd;
padding: 6px;
outline: 0;
}
.r-container > input:hover, .r-container > input:active, .r-container > input:focus {
border: 1px solid #bbb;
}
.r-container > ul.list {
margin: 0;
padding: 0;
list-style: none;
border-left: 1px solid #cdcdcd;
border-bottom: 1px solid #cdcdcd;
border-right: 1px solid #cdcdcd;
box-shadow: 1px 1px 3px #cdcdcd;
overflow: scroll;
}
.r-container > ul.list a {
cursor: default;
color: #333;
padding-left: 7px;
padding-right: 7px;
display: block;
}
.r-container > ul.list a:hover {
text-decoration: none;
background: #f1f1f1;
}
================================================
FILE: app/static/jsx/components/App.js
================================================
/** @jsx React.DOM */
define([
'react',
], function(React) {
var App = React.createClass({
getInitialState: function() {
return {
suggestions: []
}
},
getAutoSuggestions: function(keywords) {
/*
@keywords - array of keywords
Returns:
JSON Response
*/
var self = this;
if (_.isArray(keywords)) {
this._xhr = $.get('/api/complete/search?client=firefox&q=' + keywords.join('+'), function(data) {
self.setState({suggestions: data[1]})
});
}
else {
return false;
}
},
handleChange: function(e) {
var keywords = e.target.value.match(/\S+/g),
self = this;
// clear timeout if timeout is already set
if (this._t) {
clearTimeout(this._t);
}
// abort any ajax calls
if (this._xhr) {
this._xhr.abort();
}
// if no keywords then set the suggestions to empty array
if (keywords === null) {
this.setState({suggestions: []});
}
else {
this._t = setTimeout(function() { self.getAutoSuggestions(keywords) }, 500);
}
},
render: function() {
var suggestions = [];
_.forEach(this.state.suggestions, function(s, i) {
suggestions.push(<li key={i}><a>{s}</a></li>);
})
return (<div className='r-container'>
<h1>Google Auto Suggestion</h1>
<input autoFocus autoComplete='off' type='text' onChange={this.handleChange} defaultValue='' placeholder='type something here...' />
{suggestions.length > 0 ? <ul className='list'>{suggestions}</ul> : null}
</div>);
}
});
return App;
});
================================================
FILE: app/static/jsx/main.js
================================================
require.config({
paths: {
react: '../libs/react/react',
jquery: '../libs/jquery/dist/jquery.min',
lodash: '../libs/lodash/dist/lodash.min',
bootstrap: '../libs/bootstrap/dist/js/bootstrap.min'
},
shim: {
react: {
exports: 'React'
},
jquery: {
exports: '$'
},
lodash: {
exports: '_'
},
bootstrap: {
deps: ['jquery']
}
}
});
require([
'react',
'components/App',
'jquery',
'lodash',
'bootstrap'
],
function(React, App) {
React.renderComponent(App(), document.getElementById('app'));
});
================================================
FILE: app/templates/base.html
================================================
<!DOCTYPE html>
<html>
<head>
<!-- stylesheets -->
<link rel='stylesheet' href='/static/css/main.css' />
<!-- Javascript -->
<script data-main='/static/js/main' src='/static/libs/requirejs/require.js'></script>
</head>
<body>
<div id='app'></div>
</body>
</html>
================================================
FILE: bower.json
================================================
{
"name": "Flask React",
"version": "0.1.0",
"authors": [
"Abhinay Omkar <abhiomkar@gmail.com>"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"libs",
"test",
"tests"
],
"dependencies": {
"bootstrap": "~3.2.0",
"jquery": "~2.1.1",
"requirejs": "~2.1.15",
"react": "~0.11.1",
"font-awesome": "~4.2.0"
}
}
================================================
FILE: requirements.txt
================================================
Flask==0.10.1
Jinja2==2.7.3
MarkupSafe==0.23
Werkzeug==0.9.6
gunicorn==19.1.1
itsdangerous==0.24
requests==2.4.1
wsgiref==0.1.2
gitextract_u2vxkvbm/ ├── .bowerrc ├── .gitignore ├── LICENSE ├── Procfile ├── README.md ├── app/ │ ├── __init__.py │ ├── static/ │ │ ├── css/ │ │ │ ├── main.css │ │ │ └── styles.css │ │ └── jsx/ │ │ ├── components/ │ │ │ └── App.js │ │ └── main.js │ └── templates/ │ └── base.html ├── bower.json └── requirements.txt
SYMBOL INDEX (2 symbols across 1 files) FILE: app/__init__.py function index (line 11) | def index(): function api (line 15) | def api(path):
Condensed preview — 13 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (9K chars).
[
{
"path": ".bowerrc",
"chars": 37,
"preview": "{\n \"directory\": \"app/static/libs\"\n}\n"
},
{
"path": ".gitignore",
"chars": 94,
"preview": "app/static/libs/\napp/static/js/\nnode_modules\n.DS_Store\n.module-cache\nGruntfile.js\npackage.json"
},
{
"path": "LICENSE",
"chars": 1080,
"preview": "The MIT License (MIT)\n\nCopyright (c) 2014 Abhinay Omkar\n\nPermission is hereby granted, free of charge, to any person obt"
},
{
"path": "Procfile",
"chars": 34,
"preview": "web: gunicorn app:app --log-file=-"
},
{
"path": "README.md",
"chars": 1042,
"preview": "Flask React\n===========\n\nIntroduction\n------------\nBoilerplate to create a simple web app with Flask and React. Other fo"
},
{
"path": "app/__init__.py",
"chars": 876,
"preview": "import requests\nimport os\nimport json\n\nfrom flask import Flask, Response, request, session, g, redirect, url_for, abort,"
},
{
"path": "app/static/css/main.css",
"chars": 131,
"preview": "@import '../libs/bootstrap/dist/css/bootstrap.min.css';\n@import '../libs/font-awesome/css/font-awesome.css';\n\n@import 's"
},
{
"path": "app/static/css/styles.css",
"chars": 879,
"preview": ".r-container {\n\tmargin: auto;\n\twidth: 400px;\n\tmargin-top: 200px;\n}\n\n.r-container h1 {\n\tfont-family: 'Helvetica Nueu', He"
},
{
"path": "app/static/jsx/components/App.js",
"chars": 2066,
"preview": "/** @jsx React.DOM */\n\ndefine([\n 'react',\n], function(React) {\n var App = React.createClass({\n getInitialSt"
},
{
"path": "app/static/jsx/main.js",
"chars": 535,
"preview": "require.config({\n\tpaths: {\n\t\treact: '../libs/react/react',\n\t\tjquery: '../libs/jquery/dist/jquery.min',\n\t\tlodash: '../lib"
},
{
"path": "app/templates/base.html",
"chars": 282,
"preview": "<!DOCTYPE html>\n\n<html>\n\t<head>\n\t\t<!-- stylesheets -->\n\t\t<link rel='stylesheet' href='/static/css/main.css' />\n\n\t <!-"
},
{
"path": "bower.json",
"chars": 401,
"preview": "{\n \"name\": \"Flask React\",\n \"version\": \"0.1.0\",\n \"authors\": [\n \"Abhinay Omkar <abhiomkar@gmail.com>\"\n ],\n \"licens"
},
{
"path": "requirements.txt",
"chars": 128,
"preview": "Flask==0.10.1\nJinja2==2.7.3\nMarkupSafe==0.23\nWerkzeug==0.9.6\ngunicorn==19.1.1\nitsdangerous==0.24\nrequests==2.4.1\nwsgiref"
}
]
About this extraction
This page contains the full source code of the abhiomkar/flask-react GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 13 files (7.4 KB), approximately 2.3k tokens, and a symbol index with 2 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.