From Fedora Project Wiki
No edit summary |
No edit summary |
||
Line 16: | Line 16: | ||
mkdir static templates | mkdir static templates | ||
touch app.py config.py | touch app.py config.py | ||
= Dummy application = | |||
== app.py == | |||
<pre> | |||
from flask import Flask | |||
app = Flask(__name__) | |||
app.config.from_object('config') | |||
@app.route('/') | |||
@app.route('/index') | |||
def index(): | |||
return "Hello, World!" | |||
if __name__ == '__main__': | |||
app.run(host = app.config['HOST'], debug = app.config['DEBUG']) | |||
</pre> | |||
== config.py == | |||
<pre> | |||
HOST = '0.0.0.0' | |||
DEBUG = True | |||
</pre> |
Revision as of 15:32, 5 December 2012
Setup
Create directory to hold virtualenv
mkdir python_web cd python_web
Create virtualenv & install flask
wget https://raw.github.com/pypa/virtualenv/master/virtualenv.py python virtualenv.py flask source flask/bin/activate pip install flask flask-sqlalchemy flask-wtf
Create directory/file structure
mkdir hello_world cd hello_world mkdir static templates touch app.py config.py
Dummy application
app.py
from flask import Flask app = Flask(__name__) app.config.from_object('config') @app.route('/') @app.route('/index') def index(): return "Hello, World!" if __name__ == '__main__': app.run(host = app.config['HOST'], debug = app.config['DEBUG'])
config.py
HOST = '0.0.0.0' DEBUG = True