Complete the code to create a new Rails controller named 'PostsController'.
class PostsController < [1] def index # code here end end
In Rails, controllers inherit from ApplicationController to get default behavior.
Complete the code to define a Django view function that returns a simple HTTP response.
from django.http import HttpResponse def hello(request): return [1]('Hello, Django!')
Django views return an HttpResponse object to send content back to the browser.
Fix the error in this Express.js route handler to send a JSON response.
app.get('/api/data', (req, res) => { res.[1]({ message: 'Hello from Express!' }); });
Express uses res.json() to send a JSON response to the client.
Fill both blanks to create a Rails route that maps GET requests for '/articles' to the 'index' action of 'ArticlesController'.
Rails.application.routes.draw do [1] '[2]', to: 'articles#index' end
In Rails, get defines a route for GET requests. The path is '/articles'.
Fill all three blanks to create an Express.js middleware that logs the request method and URL, then calls next middleware.
app.use(([1], [2], [3]) => { console.log(`$[1].method } $[1].url`); [3](); });
Express middleware functions receive req, res, and next as parameters. Logging uses req.method and req.url. Calling next() passes control to the next middleware.