Skip to content

Server setup

bpollakw edited this page Feb 13, 2017 · 11 revisions

Start the server

Start the server. Only be sure that the port is accepting connections and accesible.

# Go to server directory
cd server
python server.py

server.py - Flask, PartsDB & Jinja2 app

This is were the Flask application handles the server requests. Database connections are performed through PartsDB and redirects are rendered through the template engine Jinja2. The frontend is generated primarily by the layout.html file (in the templates directory) which includes the corresponding template. Each template loads required Javascript libraries and yields the webpage.

Be sure to run server.py with the appropriate database argument:

python server.py [DATABASE]

For example in:

@app.route('/help')
def help():
	return render_template("help.html", title='Help')

The application root address (http://marpodb.io/help), yields the instruction for the template engine to include the help.html into layout.html.

In layout.html, after the <head>, the container <div> will include the appropriate template defined in the application route:

<div id="container" class="container">
...
{% block content %}
{% endblock %}
</div>

In help.html:

{% extends "layout.html" %}
{% block content %}
...
{% endblock %}

See PartsDB to see how to perform queries to the database.

Clone this wiki locally