Skip to content

Simple portfolio website template using Flask

Notifications You must be signed in to change notification settings

jjayeon/flask-blog

 
 

Repository files navigation

Flask-Blog

Minimal Flask template to get started on your blog application for MLH Fellowship Production Engineering track.

Installation

Make sure you have python3 and pip installed. On Ubuntu/Debian, it looks something like this:

apt install python3
apt install pip
# replace "apt" with the package manager of your choice.

You may also need to install venv:

apt install python3-venv

Create and activate virtual environment using virtualenv.

~/your/path/here$ python3 -m venv python3-virtualenv

# creates a directory python3-virtual env in the current directory,
# which contains all the files for a new virtual environment.

~/your/path/here$ source python3-virtualenv/bin/activate

# tells the command line to enter the above virtual environment.

Afterwards, your command prompt might look something like this:

(python3-virtualenv) name@computer:~/your/path/here$

And you can make extra sure it's working properly in the Python interpreter:

>>> import sys
>>> sys.path
[..., '~/your/path/here/python3-virtualenv/lib/python3.8/site-packages']

While using the virtual environment, use the package manager pip to install all dependencies.

pip install -r requirements.txt

This should install click, Flask, itsdangerous, Jinja2, MarkupSafe, python_dotenv, and Werkzeug.

Usage

Create a .env file using the example.env template.

Start flask develpment server.

  1. Add FLASK_ENV=development to .env
$ docker-compose up
  1. You should see a message that specifies the IP at which the app is hosted: 127.0.0.1:5000. Open that address in your browser to confirm that the app is working.

A Beginner's Guide to Flask

Flask is a micro web framework written in Python. The idea behind Flask is to convert HTTP requests into function calls Python can understand; this is accomplished through the use of routes, as in our init file:

@app.route('/')
def index():
    return render_template('index.html', title="MLH Fellow", url=os.getenv("URL"))

The above code translates as follows: when we receive a request with the URL '/', give the user the HTML resulting from the render_template() call.

render_template() is a function that takes a template ('index.html'), some arguments to the template (title="MLH Fellow", url=os.getenv("URL")), and returns a complete HTML file. The "template" in question is a Jinja2 template, which basically lets you insert {{ variables }} into an a reusable HTML template. (Other features and file formats are supported as well.) You can check out this repo's index page for an example.

This project will involve writing new routes and templates to grow this simple placeholder code into a fully-fledged portfolio. See this demo for an example of how it might look.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

About

Simple portfolio website template using Flask

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 45.6%
  • HTML 24.6%
  • CSS 15.1%
  • Shell 10.6%
  • Mako 2.8%
  • Dockerfile 1.3%