diff --git a/Makefile b/Makefile index fdf5c9d..a8b035d 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ default: run run: - FLASK_APP=app flask run \ No newline at end of file + FLASK_ENV=development FLASK_APP=app flask run diff --git a/app.py b/app.py index b635c07..bbe37d6 100644 --- a/app.py +++ b/app.py @@ -1,22 +1,20 @@ from flask import Flask, render_template from flask_wtf import FlaskForm +from flask_wtf.csrf import CSRFProtect +from flask_wtf.file import FileField, FileRequired from wtforms import StringField from wtforms.validators import DataRequired app = Flask(__name__) +app.config["SECRET_KEY"] = "foo" +app.config["WTF_CSRF_SECRET_KEY"] = "bar" -@app.route("/") -def hello_world(): - form = MyForm(meta={"csrf": False}) - return render_template("index.html", form=form) - +class UploadForm(FlaskForm): + pdf = FileField(validators=[FileRequired()]) -class MyForm(FlaskForm): - name = StringField("name", validators=[DataRequired()]) - -@app.route("/submit", methods=["GET", "POST"]) -def submit(): - print("Success!") - return render_template("index.html") +@app.route("/") +def home(): + form = UploadForm() + return render_template("index.html", form=form) diff --git a/templates/index.html b/templates/index.html index 47cb5e4..bafc157 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,15 +1,15 @@ - - - - THIS IS A TITLE - - -
- {{ form.csrf_token }} - {{ form.name.label }} {{ form.name(size=20) }} - -
- - \ No newline at end of file + + + + THIS IS A TITLE + + +
+ {{ form.csrf_token }} + + +
+ +