provide admin_prefix
This commit is contained in:
parent
1785c34deb
commit
55eb6d070e
|
@ -9,3 +9,4 @@ class Config(object):
|
||||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||||
STATIC_FOLDER = f"{os.getenv('APP_FOLDER')}/forest/static"
|
STATIC_FOLDER = f"{os.getenv('APP_FOLDER')}/forest/static"
|
||||||
MEDIA_FOLDER = f"{os.getenv('APP_FOLDER')}/forest/media"
|
MEDIA_FOLDER = f"{os.getenv('APP_FOLDER')}/forest/media"
|
||||||
|
ADMIN_PREFIX = "fadmin"
|
||||||
|
|
|
@ -1,57 +0,0 @@
|
||||||
import os
|
|
||||||
|
|
||||||
from werkzeug.utils import secure_filename
|
|
||||||
from flask import (
|
|
||||||
Flask,
|
|
||||||
jsonify,
|
|
||||||
send_from_directory,
|
|
||||||
request,
|
|
||||||
redirect,
|
|
||||||
url_for
|
|
||||||
)
|
|
||||||
from flask_sqlalchemy import SQLAlchemy
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
|
||||||
app.config.from_object("project.config.Config")
|
|
||||||
db = SQLAlchemy(app)
|
|
||||||
|
|
||||||
|
|
||||||
class User(db.Model):
|
|
||||||
__tablename__ = "users"
|
|
||||||
|
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
|
||||||
email = db.Column(db.String(128), unique=True, nullable=False)
|
|
||||||
active = db.Column(db.Boolean(), default=True, nullable=False)
|
|
||||||
|
|
||||||
def __init__(self, email):
|
|
||||||
self.email = email
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/")
|
|
||||||
def hello_world():
|
|
||||||
return jsonify(hello="world")
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/static/<path:filename>")
|
|
||||||
def staticfiles(filename):
|
|
||||||
return send_from_directory(app.config["STATIC_FOLDER"], filename)
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/media/<path:filename>")
|
|
||||||
def mediafiles(filename):
|
|
||||||
return send_from_directory(app.config["MEDIA_FOLDER"], filename)
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/upload", methods=["GET", "POST"])
|
|
||||||
def upload_file():
|
|
||||||
if request.method == "POST":
|
|
||||||
file = request.files["file"]
|
|
||||||
filename = secure_filename(file.filename)
|
|
||||||
file.save(os.path.join(app.config["MEDIA_FOLDER"], filename))
|
|
||||||
return """
|
|
||||||
<!doctype html>
|
|
||||||
<title>upload new File</title>
|
|
||||||
<form action="" method=post enctype=multipart/form-data>
|
|
||||||
<p><input type=file name=file><input type=submit value=Upload>
|
|
||||||
</form>
|
|
||||||
"""
|
|
Loading…
Reference in a new issue