-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
40 lines (26 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
from flask import *
app = Flask(__name__)
from flask import Blueprint, render_template, flash
from flask_login import login_required, current_user
from __init__ import create_app, db
# our main blueprint
main = Blueprint('main', __name__)
@main.route('/') # home page that return 'index'
def index():
return render_template('index.html')
@main.route('/profile') # profile page that return 'profile'
@login_required
def profile():
return render_template('profile.html', name=current_user.name)
app = create_app() # we initialize our flask app using the __init__.py function
if __name__ == '__main__':
db.create_all(app=create_app()) # create the SQLite database
#app.run(debug=True) # run the flask app on debug mode
@main.route('/success', methods = ['POST'])
def success():
if request.method == 'POST':
f = request.files['file']
f.save(f.filename)
return render_template("success.html", name = f.filename)
if __name__ == '__main__':
app.run(port=5000, debug=True)