Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def new():
title = request.form['title']
slug = slugify(title)
content = request.form['content']
date = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
entry = Entry.save_draft(title, content, date, slug)
filepath = os.path.join('./summer/_draft/', slug + '.md')
newfile = open(filepath, 'w')
meta = yaml.safe_dump({
'title': title,
'date': date,
'tags': [''],
'categories': ['']
}, default_flow_style=False).replace('- ', ' - ')
newfile.write(meta + '\n')
newfile.write('---' + '\n\n')
newfile.write(content.encode('utf8'))
newfile.write('\n')
newfile.close()