code: def new(obj):
      
      title = request.form['title']
      _site.config['ADDITIONAL_METADATA']['author.uid'] = current_user.uid
      try:
          title = title.encode(sys.stdin.encoding)
      except (AttributeError, TypeError):
          title = title.encode('utf-8')
      try:
          if obj == 'post':
              f = NewPostForm()
              if f.validate():
                  _site.commands.new_post(title=title,
                                          author=current_user.realname,
                                          content_format='html')
              else:
                  return error("Bad Request", 400)
          elif obj == 'page':
              f = NewPageForm()
              if f.validate():
                  _site.commands.new_page(title=title,
                                          author=current_user.realname,
                                          content_format='html')
              else:
                  return error("Bad Request", 400)
          else:
              return error("Cannot create {0} — unknown type.".format(obj), 400)
      except SystemExit:
          return error("This {0} already exists!".format(obj), 500)
      finally:
          del _site.config['ADDITIONAL_METADATA']['author.uid']
      # reload post list and go to index
      scan_site()
      if db is not None:
          db.set('site:needs_rebuild', '1')
      else:
          site.coil_needs_rebuild = '1'
      return redirect(url_for('index'))
docs: Create a new post or page.
  
      :param str obj: Object to create (post or page)