forked from Dimama/RSOI-lab1-Simple-Server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
44 lines (29 loc) · 1.07 KB
/
app.py
File metadata and controls
44 lines (29 loc) · 1.07 KB
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
from flask import Flask, render_template, request
from functions import is_palindrome, possible_palindrome
import os
app = Flask(__name__)
@app.route('/possible', methods=['GET'])
def possible_palindrome_route():
word = request.args.get('word')
if word is None:
return render_template('usage.html', error=True)
res = possible_palindrome(word)
return render_template('result.html',
name="Is possible to make palindrome from sequence?", word=word, res=res)
@app.route('/ispalindrome', methods=['GET'])
def is_palindrome_route():
word = request.args.get('word')
if word is None:
return render_template('usage.html', error=True)
res = is_palindrome(word)
return render_template('result.html',
name="Is sequence a palindrome?", word=word, res=res)
@app.route('/')
def hello_world():
return render_template('usage.html', error=False)
@app.route('/', defaults={'path': ''})
@app.route('/<path:path>')
def catch_all(path):
return render_template('usage.html', error=True)
if __name__ == '__main__':
app.run()