Quiz 2
Registry Synced

Learning Objectives

207 words
1 min read

Reading compass

Now · Step 1: File Upload

Learning Objectives

  • Implement search, pagination, file upload
  • Deploy to Heroku/Vercel
  • Configure environment variables
  • Application functional locally
  • Git repository clean
  • Heroku/Vercel account

Step 1: File Upload

python
# backend/upload.py
import os
from flask import Blueprint, request, jsonify
from werkzeug.utils import secure_filename
UPLOAD_FOLDER = 'uploads'
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif'}
upload = Blueprint('upload', __name__)
def allowed_file(filename):
    return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
@upload.route('/upload', methods=['POST'])
def upload_file():
    if 'file' not in request.files:
        return {'msg': 'No file part'}, 400
    file = request.files['file']
    if file.filename == '':
        return {'msg': 'No selected file'}, 400
    if file and allowed_file(file.filename):
        filename = secure_filename(file.filename)
        file.save(os.path.join(UPLOAD_FOLDER, filename))
        return {'url': f'/uploads/{filename}'}, 201

Step 2: Deploy to Heroku

bash
# Create Procfile
echo "web: gunicorn app:app" > Procfile
# Create runtime.txt
echo "python-3.9.18" > runtime.txt
# Deploy
heroku create your-app-name
git push heroku main
heroku config:set SECRET_KEY=your-secret
Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.