-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
55 lines (44 loc) · 1.21 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
'''
Author - Sean Beck
The main app for the flask application Cron Configure
'''
import os
from flask import Flask, render_template, send_from_directory
from flask_bootstrap import Bootstrap
from forms import CronForm
APP = Flask(__name__)
APP.config['SECRET_KEY'] = 'poop'
Bootstrap(APP)
def prepend_star(target):
'''
Prepends a * if the specified string starts with /
'''
if '/' in target:
return '*'+target
else:
return target
def create_string(form):
'''
Creates the configuration string
'''
res = ''
res += prepend_star(form.minute.data) + ' '
res += prepend_star(form.hour.data) + ' '
res += prepend_star(form.day.data) + ' '
res += form.month.data + ' '
res += form.weekday.data + ' '
res += 'your command goes here'
return res
@APP.route('/', methods=['GET', 'POST'])
def index():
'''
Handles GET and POST requests to the index
'''
form = CronForm()
result = ''
if form.validate_on_submit():
result = create_string(form)
return render_template('index.html', form=form, result=result)
if __name__ == '__main__':
PORT = int(os.environ.get("PORT", 5000))
APP.run(debug=True, host='0.0.0.0', port=PORT)