def add_entry():
   #g.db.execute('insert into entries (title, text) values (?, ?)', [request.form['title'], request.form['text']])
   #g.db.commit()

   #spacedJobTitle = request.form['jobtitle']
   jobTitle = request.form['jobtitle'].title()
   #jobTitle = request.form['jobtitle'].replace(" ", "+")
   scraping = False
   try:
      newJob, jobtitleFilename, jobbulletFilename = readJobs.existingJob(jobTitle, scraping)
      if newJob:
         readJobs.mainReadJobs(jobTitle, jobtitleFilename, jobbulletFilename, 5)
      #creating the opening and closing 
      jobfile = codecs.open(jobtitleFilename, encoding='utf-8')
      markov = markovgen.Markov(jobfile)

      sentences = random.randint(2, 3)
      theOpening = markov.generate_markov_text(sentences)
      flash(theOpening,'theOpening' )

      sentences = random.randint(2, 3)
      theClosing = markov.generate_markov_text(sentences)
      flash(theClosing,'theClosing')

      if( os.path.isfile(jobbulletFilename) ):
         bulletHeader = [ 'Key Responsibilities', 'Duties', 'Key Duties and Responsibilities', 'Objectives', 'Qualifications', 'Main Responsibilities']
         flash(random.choice(bulletHeader),'bulletHeader')
         #creating in the bullet points
         file = codecs.open(jobbulletFilename, encoding='utf-8')
         markovBullets = markovgen.MarkovBullets(file)
      flash(jobTitle,'jobtitleMsg' )
      sentences = random.randint(5, 7)
      theBullets = markovBullets.generate_markov_text(sentences)
      flash(theBullets,'bullets' )
      addInDatabase(jobTitle)
   except:
      flash("There was an error in your request....Try Again",'error')  
   return redirect(url_for('show_entries'))
    'Web Developer',
    'Sofware Engineer',
    'Casher',
    'Sales representative',
    'Supervisor',
    'Labourer',
    'Project Engineer',
    'Junior Engineer',
    'Intermediate Engineer',
    'Senior Engineer',
    'QA Engineer',
    'Designer',
    'Design Engineer',
    'Drafter',
    'Manufacturing Engineer',
    'Web Administrator',
    'Web Designer',
    'Freelance Writer',
    'Mechatronics Engineer',
]

scraping = True

print "Starting to Scrape jobs"
for jobTitle in scrapedJobs:
    newJob, jobtitleFilename, jobbulletFilename = readJobs.existingJob(
        jobTitle, scraping)
    if newJob:
        readJobs.mainReadJobs(jobTitle, jobtitleFilename, jobbulletFilename,
                              200)
        print "Finished Scraping %s" % jobTitle
'Manager',
'Web Developer',
'Sofware Engineer',
'Casher',
'Sales representative',
'Supervisor',
'Labourer',
'Project Engineer',
'Junior Engineer',
'Intermediate Engineer',
'Senior Engineer',
'QA Engineer',
'Designer',
'Design Engineer',
'Drafter',
'Manufacturing Engineer',
'Web Administrator',
'Web Designer',
'Freelance Writer',
'Mechatronics Engineer',
]


scraping = True

print "Starting to Scrape jobs"
for jobTitle in scrapedJobs:
	newJob, jobtitleFilename, jobbulletFilename = readJobs.existingJob(jobTitle, scraping)
	if newJob:
		readJobs.mainReadJobs(jobTitle, jobtitleFilename, jobbulletFilename, 200)
		print "Finished Scraping %s" % jobTitle