Easy blog add-on for Python Flask web apps. Most blogs are designed to work as standalone applications; this blog engine is something you can super easily add to an existing Python Flask web app, so that your blog will have the same styling as the rest of your app.
-
Runs on a single-file SQLite database
-
Blog administrators log in with their Gmail accounts
-
You write blog posts in Markdown, and code blocks have syntax highlighting
-
Install using pip:
pip install integratedblog
(Note: this is not yet publicly on pip; you need to clone this repo,cd
into it, and runpython setup.py install
) -
Set up a Google OAuth client for logging in to your blog: Go to the Google APIs API Manager -> Credentials (https://console.developers.google.com/apis/credentials). Click Create Credentials -> OAuth client ID -> Web application.
-
Grab the Client ID and Client Secret- you'll use them in Step 3
-
Fill in Authorized Redirect URIs with your website's URL, and with any URLs you'll use for development and testing. For example,
http://example.com/blog/admin/oauth2callback
andhttp://localhost:5000/blog/admin/oauth2callback
. Replace the wordblog
in/blog/admin/oauth2callback
with whatever you want the URL extension of your blog to be: for example,/my_awesome_blog/admin/oauth2callback
. See in Step 3 how to customize the URL extension.
-
-
Add configuration steps to your
app.py
file:from integratedblog.blog_pages import blog_pages from integratedblog.data_models import set_up_blog_db ... # Anywhere after you've defined "app": app.config['BLOG_DATA'] = { 'authorized_emails': set(["[email protected]", "[email protected]"]), # Blog administrators with these Gmail addresses can log in 'oauth_client_id': GOOGLE_OAUTH_CLIENT_ID, # Get this from step 2 'oauth_client_secret': GOOGLE_OAUTH_CLIENT_SECRET # Get this from step 2 } set_up_blog_db('blog.db') # Set the filepath for your SQLite database file app.register_blueprint(blog_pages, url_prefix="/blog") # url_prefix is the URL extension for your blog
-
Add template files for the blog pages
-
Create authors: open an
ipython
terminal, and in it, do the following:In [1]: from integratedblog.data_models import Author, set_up_blog_db In [2]: set_up_blog_db('/filepath/of/database.db') In [3]: Author.create(name="Washington Irving") # Do this for every Author you want to create
-
You're ready to blog! Log in by going to
example.com/blog/admin/login
, click "Create new blog post", and check that the list of authors you created has correctly populated the dropdown.