-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
42 lines (33 loc) · 1.01 KB
/
main.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
from flask import Flask, render_template, url_for, request, redirect, session , Markup
import requests
import markdown
app = Flask(__name__)
app.secret_key = 'mysecretkey'
def get_quote():
url = f'https://api.quotable.io/random?tag={session["tag"]}'
response = requests.get(url)
data = response.json()
content = data['content']
author = data['author']
quote = [content, author]
return quote
@app.route('/')
def main():
return render_template('index2.html')
@app.route('/show')
def display():
quote = get_quote()
content = quote[0]
author = quote[1]
return render_template('index.html', content=content, author=author)
@app.route('/quotes', methods=['GET', 'POST'])
def quotes():
if request.method == 'POST':
category = request.form.get('category')
session['tag'] = category
return redirect(url_for('display'))
@app.route('/markdown')
def markdown():
return render_template('temp.html')
if __name__ == '__main__':
app.run(host='0.0.0.0',port=80)