Skip to content
Myr

Updated the examples to be cli based

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 3be7d91 · Browse files · 6 files+26 added−33 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

6 files+26 added−33 removed

  • other:+26 added−33 removed

6 files+26 added−33 removed

modified:examples/blueprintexample/blueprintexample.py+1 added-5 removed
2 unmodified lines
34app = Flask(__name__)5app.register_blueprint(simple_page)6# Blueprint can be registered many times7app.register_blueprint(simple_page, url_prefix='/pages') 8910if __name__ == '__main__':11 app.run(debug=True)7app.register_blueprint(simple_page, url_prefix='/pages')
modified:examples/flaskr/README+10 added-3 removed
11 unmodified lines
12 1. edit the configuration in the flaskr.py file or13 export an FLASKR_SETTINGS environment variable14 pointing to a configuration file.1516 2. now you can run the flaskr.py file with your17 python interpreter and the application will18 greet you on http://localhost:5000/16 2. initialize the database with this command:1718 flask --app=flaskr initdb1920 3. now you can run flaskr:2122 flask --app=flaskr run2324 the application will greet you on25 http://localhost:5000/26 27 ~ Is it tested?2829 You betcha. Run the `flaskr_tests.py` file to see
1 unmodified line
modified:examples/jqueryexample/jqueryexample.py-4 removed
21 unmodified lines
2223@app.route('/')24def index():25 return render_template('index.html')262728if __name__ == '__main__':29 app.run()
modified:examples/minitwit/minitwit.py+7 added-12 removed
47 unmodified lines
48 if hasattr(top, 'sqlite_db'):49 top.sqlite_db.close()505152@app.cli.command()52def init_db():53def initdb():54 """Creates the database tables."""54 with app.app_context():55 db = get_db()56 with app.open_resource('schema.sql', mode='r') as f:57 db.cursor().executescript(f.read())58 db.commit()55 db = get_db()56 with app.open_resource('schema.sql', mode='r') as f:57 db.cursor().executescript(f.read())58 db.commit()596061def query_db(query, args=(), one=False):62 """Queries the database and returns a list of dictionaries."""
153 unmodified lines
216 if request.method == 'POST':217 if not request.form['username']:218 error = 'You have to enter a username'219 elif not request.form['email'] or \220 '@' not in request.form['email']:220 '@' not in request.form['email']:221 error = 'You have to enter a valid email address'222 elif not request.form['password']:223 error = 'You have to enter a password'224 elif request.form['password'] != request.form['password2']:
22 unmodified lines
247248# add some filters to jinja249app.jinja_env.filters['datetimeformat'] = format_datetime250app.jinja_env.filters['gravatar'] = gravatar_url251252253if __name__ == '__main__':254 init_db()255 app.run()
modified:examples/minitwit/README+8 added-5 removed
12 unmodified lines
13 1. edit the configuration in the minitwit.py file or14 export an MINITWIT_SETTINGS environment variable15 pointing to a configuration file.1617 2. fire up a python shell and run this:17 2. fire up a shell and run this:1819 >>> from minitwit import init_db; init_db()19 flask --app=minitwit initdb2021 3. now you can run the minitwit.py file with your22 python interpreter and the application will23 greet you on http://localhost:5000/21 3. now you can run minitwit:2223 flask --app=minitwit run2425 the application will greet you on26 http://localhost:5000/27 28 ~ Is it tested?2930 You betcha. Run the `minitwit_tests.py` file to
1 unmodified line
modified:examples/persona/persona.py-4 removed
51 unmodified lines
52 out again.53 """54 session.clear()55 return 'OK'565758if __name__ == '__main__':59 app.run()