-
Notifications
You must be signed in to change notification settings - Fork 1
/
FlaskDemo1.txt
57 lines (45 loc) · 996 Bytes
/
FlaskDemo1.txt
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
56
57
create API using Flask :
```
from flask import Flask,render_template
app = Flask(__name__)
@app.route('/index')
def index1():
print('I am in index')
return('index 1')
@app.route('/flaskdemo1')
def index2():
return render_template('flaskdemo1.html')
@app.route('/about')
def about():
return render_template('abouthtml.html')
if __name__ == '__main__':
app.run(host='0.0.0.0', port=1380)
```
In the template folder place flaskdemo1.html
```
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>my flask demo</title>
</head>
<body>
<h1>this is a demo</h1>
</body>
</html>
```
and another file abouthtml.html
```
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>this is about</title>
<link rel="stylesheet" href="{{ url_for('static',filename='css/styles.css') }}">
</head>
<body>
<p id="pp">I am working on flask and is about page</p>
<a href="{{ url_for('index1') }}">tst</a>
</body>
</html>
```