You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.2 KiB

2 years ago
from flask import request, jsonify, redirect, url_for, render_template
# from flask_login import LoginManager, login_user, logout_user, login_required, current_user
2 years ago
from app import app, db
from app.models import User
# login_manager = LoginManager()
# login_manager.init_app(app)
# login_manager.login_view = 'login'
2 years ago
# @login_manager.user_loader
# def load_user(user_id):
# return User.query.get(int(user_id))
2 years ago
@app.route('/api', methods=['POST'])
# @login_required
2 years ago
def process_request():
image = request.files.get('image')
text = request.form.get('text')
blocks = request.form.getlist('blocks')
# Process image, text, and blocks as needed
2 years ago
# log to flask log the blocks list.
app.logger.info(blocks)
app.logger.info(text)
2 years ago
return jsonify(success=True)
# @app.route('/signup', methods=['GET', 'POST'])
# def signup():
# if current_user.is_authenticated:
# return redirect(url_for('process_request'))
2 years ago
# if request.method == 'POST':
# username = request.form['username']
# password = request.form['password']
# user = User.query.filter_by(username=username).first()
2 years ago
# if user is None:
# new_user = User(username=username)
# new_user.set_password(password)
# db.session.add(new_user)
# db.session.commit()
# return redirect(url_for('login'))
# else:
# return "User already exists"
2 years ago
# return render_template('signup.html')
2 years ago
# @app.route('/login', methods=['GET', 'POST'])
# def login():
# if current_user.is_authenticated:
# return redirect(url_for('process_request'))
2 years ago
# if request.method == 'POST':
# username = request.form['username']
# password = request.form['password']
# user = User.query.filter_by(username=username).first()
2 years ago
# if user and user.check_password(password):
# login_user(user)
# return redirect(url_for('process_request'))
# else:
# return "Invalid username or password"
2 years ago
# return render_template('login.html')
2 years ago
# @app.route('/logout')
# @login_required
# def logout():
# logout_user()
# return redirect(url_for('login'))