from flask import Flask, render_template
import yaml

import orcid

app = Flask(__name__)


@app.route('/')
def index():
    with open("config.yml", 'r') as ymlfile:
        cfg = yaml.load(ymlfile)

    name = cfg['user']['name']
    affiliation = cfg['user']['affiliation']
    gravatarhash = cfg['user']['gravatarhash']
    articles = cfg['articles']
    for article in articles:
        articles[article]['doiurl'] = "http://dx.doi.org/" + \
            articles[article]['doi']
    return render_template('sample.html',
                           profile_data={
                           "user": cfg['user'],
                           "name": name,
                           "affiliation": affiliation,
                           "gravatarhash": gravatarhash},
                           articles=articles)

@app.route('/<orcid_id>')
def storify(orcid_id):
    orcid_json = orcid.get_json(orcid_id)
    return render_template('sample.html',
                           profile_data=orcid_json,
                           articles={})

if __name__ == '__main__':
    app.run(debug=True)

@@ -376,16 +376,66 @@
 ticles:%0A
+        if 'doi' in articles%5Barticle%5D.keys():%0A    
         
@@ -493,32 +493,36 @@
 + %5C%0A            
+    
 articles%5Barticle
@@ -530,16 +530,77 @@
 %5B'doi'%5D%0A
+        else:%0A            articles%5Barticle%5D%5B'doiurl'%5D = None%0A
     retu

Handle missing dois