-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathmain.py
More file actions
49 lines (41 loc) · 1.38 KB
/
main.py
File metadata and controls
49 lines (41 loc) · 1.38 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
45
46
47
48
49
#!/usr/bin/python
from flask import Flask, escape, request
from flask import Flask, url_for
from markupsafe import escape
from flask import render_template
import logging
# Create an instance of this class
app = Flask(__name__)
# Logging configuration
logging.basicConfig(filename='demo.log', level=logging.DEBUG)
# Use the route() decorator to bind a function to a URL.
@app.route('/')
def index():
app.logger.info('Processing default request')
#return 'Index Page'
return render_template('index.html')
@app.route('/index.html')
def index_html():
return render_template('index.html')
@app.route('/<string:page_name>')
def html_page(page_name):
return render_template(page_name)
# You can add variable sections to a URL by marking sections with <variable_name>.
@app.route('/<username>')
def hello_html(username=None):
return render_template('username.html', name=username)
@app.route('/submit_form', methods=['POST', 'GET'])
def submit_form():
error = None
if request.method == 'POST':
# data =request.form['email']
data = request.form.to_dict()
print(data)
return('form submitted')
else:
error = 'some error'
# the code below is executed if the request method
# was GET or the credentials were invalid
return render_template('login.html', error=error)
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0')