Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- from flask import Flask, request, redirect, flash
- from werkzeug.utils import secure_filename
- UPLOAD_FOLDER = '/cats'
- ALLOWED_EXTENSIONS = {'txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'}
- app = Flask(__name__)
- app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
- @app.route('/')
- def index():
- #something connected with frontend i guess, but found no examples of this
- return "hejkan aklejka"
- @app.route('/upload', methods=['POST'])
- def upload():
- if 'file' not in request.files:
- flash('No file part')
- return redirect(request.url)
- file = request.files['file']
- if file.filename == '':
- flash('No selected file')
- return redirect(request.url)
- if file and allowed_file(file.filename):
- filename = secure_filename(file.filename)
- file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
- main(filename)
- """
- @app.route('/cat', methods=['GET'])
- def cat():
- #what should i put instead of questionmark?
- return is_cat(?)
- """
- if __name__ == "__main__":
- app.run(debug=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement