tornado/demos/blog
Ben Darnell b909d37e54 docs,demos: Update for asyncio.run pattern
Adapt for Python 3.10 deprecation changes by using asyncio.run
instead of IOLoop.start throughout (except for TCPServer multi-process
docs).

Demos have all been changed but I haven't tested all of them.
2022-06-03 14:50:20 -04:00
..
static Move Tornado project to Github 2009-09-10 00:50:51 -07:00
templates Simplify HTML templates by using HTML5 2015-08-16 08:51:06 +02:00
Dockerfile build: Add Python 3.7 to tox and appveyor configs 2018-07-10 21:13:32 -04:00
README Drop support for python 3.5 2020-10-31 08:38:17 -04:00
blog.py docs,demos: Update for asyncio.run pattern 2022-06-03 14:50:20 -04:00
docker-compose.yml demos: Update blog demo 2018-05-13 15:07:15 -04:00
requirements.txt demos: Update blog demo 2018-05-13 15:07:15 -04:00
schema.sql demos: Update blog demo 2018-05-13 15:07:15 -04:00

README

Running the Tornado Blog example app
====================================

This demo is a simple blogging engine that uses a database to store posts.
You must have PostgreSQL or CockroachDB installed to run this demo.

If you have `docker` and `docker-compose` installed, the demo and all
its prerequisites can be installed with `docker-compose up`.

1. Install a database if needed

   Consult the documentation at either https://www.postgresql.org or
   https://www.cockroachlabs.com to install one of these databases for
   your platform.

2. Install Python prerequisites

   This demo requires Python 3.6 or newer, and the packages listed in
   requirements.txt. Install them with `pip -r requirements.txt`

3. Create a database and user for the blog.

   Connect to the database with `psql -U postgres` (for PostgreSQL) or
   `cockroach sql` (for CockroachDB).

   Create a database and user, and grant permissions:

   CREATE DATABASE blog;
   CREATE USER blog WITH PASSWORD 'blog';
   GRANT ALL ON DATABASE blog TO blog;

   (If using CockroachDB in insecure mode, omit the `WITH PASSWORD 'blog'`)

4. Create the tables in your new database (optional):

   The blog application will create its tables automatically when starting up.
   It's also possible to create them separately.

   You can use the provided schema.sql file by running this command for PostgreSQL:

   psql -U blog -d blog < schema.sql

   Or this one for CockcroachDB:

   cockroach sql -u blog -d blog < schema.sql

   You can run the above command again later if you want to delete the
   contents of the blog and start over after testing.

5. Run the blog example

   For PostgreSQL, you can just run
   ./blog.py

   For CockroachDB, run
   ./blog.py --db_port=26257

   If you've changed anything from the defaults, use the other `--db_*` flags.

6. Visit your new blog

   Open http://localhost:8888/ in your web browser.

   Currently the first user to connect will automatically be given the
   ability to create and edit posts.

   Once you've created one blog post, subsequent users will not be
   prompted to sign in.