title: Schedule jobs dynamically with Flask APScheduler
body: <p>I'm trying the code given at <a href="https://github.com/viniciuschiele/flask-apscheduler/blob/master/examples/advanced.py" rel="nofollow noreferrer"> advanced.py</a> with the following modification for adding new jobs.</p>
  
  <p>I created a route for adding a new job</p>
  
  <pre><code>@app.route('/add', methods = ['POST'])
  def add_to_schedule():
      data = request.get_json()
      print(data)
  
      d = {
          'id': 'job'+str(random.randint(0, 100)),
          'func': 'flask_aps_code:job1',
          'args': (random.randint(200,300),random.randint(200, 300)),
          'trigger': 'interval',
          'seconds': 10
  
      }
      print(app.config['JOBS'])
      scheduler.add_job(id = 'job'+str(random.randint(0, 100)), func = job1)
      #app.config.from_object(app.config['JOBS'].append(d))
      return str(app.config['JOBS']), 200
  </code></pre>
  
  <p>I tried adding the jobs to config['JOBS'] as well as scheduler.add_job. But none of my new jobs are not getting executed. Additionally, my first scheduled job doesnt get executed till I do a ctrl+c on the terminal, after which the first <a href="https://github.com/viniciuschiele/flask-apscheduler/blob/master/examples/advanced.py#L9" rel="nofollow noreferrer">scheduled job seems to execute</a>, twice. What am I missing?</p>
  
  <p>Edit: Seemingly the job running twice is because of <a href="https://stackoverflow.com/questions/14874782/apscheduler-in-flask-executes-twice">flask reloading</a>, so ignore that.</p>