Related Coding Blogs

Practice Top 30 Python Programming Questions on Web Development Basics, TechnoVlogs

Practice Top 30 Python Programming Questions on Web Development Basics


Q1. Write a simple Flask application that returns "Hello, World!" on the homepage.

Input: Access the route /.
Expected Output: Hello, World!

Q2. Add a route /about that returns "About Page".

Input: Access the route /about.
Expected Output: About Page

Q3. Create a route /user/ that displays "Welcome, ".

Input: Access /user/Alice.
Expected Output: Welcome, Alice

Q4. Write a Flask route /api/data that returns a JSON object {"status": "success", "data": [1, 2, 3]}.
Input: Access /api/data.
Expected Output: {"status": "success", "data": [1, 2, 3]}

Q5. Render an HTML template index.html for the / route with the title "Home".
Input: Access /.
Expected Output: An HTML page with the title Home.

Q6. Pass the variable name="Alice" to the template index.html.
Input: Access /.
Expected Output: HTML displaying Hello, Alice.

Q7. Handle a GET request to /search?query=Python and display the query parameter.
Input: Access /search?query=Python.
Expected Output: You searched for Python

Q8. Create a route /submit that accepts POST data and returns "Data Submitted".
Input: POST {"name": "Alice"} to /submit.
Expected Output: Data Submitted

Q9. Serve a static CSS file style.css to style the page.
Input: Access /static/style.css.
Expected Output: CSS content.

Q10. Add a custom 404 error handler that returns "Page Not Found".
Input: Access a nonexistent route.
Expected Output: Page Not Found

Q11. Set up a Django project and app, and display "Welcome to Django!" on the home route.
Input: Access /.
Expected Output: Welcome to Django!

Q12. Create a path /user// that displays "Hello, ".
Input: Access /user/Bob/.
Expected Output: Hello, Bob

Q13. Render a template home.html with a context variable message="Hello, Django!".
Input: Access /.
Expected Output: HTML page with Hello, Django!.

Q14. Create a Book model with fields title and author. Display a list of books on /books/.
Input: Add Book(title="Django", author="Alice").
Expected Output: HTML page listing Django by Alice.

Q15. Register the Book model in the Django admin panel.
Input: Access /admin/ and add a book.
Expected Output: Book appears in the list.

Q16. Create an API /api/greet/ that returns {"message": "Hello, "}.
Input: Access /api/greet/Alice.
Expected Output: {"message": "Hello, Alice"}

Q17. Create an API /api/items that returns a list ["item1", "item2"].
Input: Access /api/items.
Expected Output: ["item1", "item2"]

Q18. Create an API /api/add that accepts POST data and returns the data with a success message.
Input: POST {"name": "item1"}.
Expected Output: {"status": "success", "name": "item1"}

Q19. Return a 400 error for a missing name field in a POST request to /api/add.
Input: POST {}.
Expected Output: {"error": "Missing field: name"}

Q20. Create an API /api/items?page=1 that returns 2 items per page from a list.
Input: Access /api/items?page=1.
Expected Output: ["item1", "item2"]

Q21. Create a form in Flask to accept a user's name and display it.
Input: Enter Alice in the form.
Expected Output: Hello, Alice!

Q22. Use template inheritance in Flask/Django with a base template and a child template.
Input: Render child template extending base.
Expected Output: Complete page with inherited structure.

Q23. Add data to a SQLite database using Django's ORM.
Input: Add {"title": "Book", "author": "Bob"}.
Expected Output: Book by Bob appears in the list.

Q24. Use SQLAlchemy in Flask to store a user's name and display it.
Input: Add Alice to the database.
Expected Output: Hello, Alice

Q25. Validate that the name field is not empty in a Flask form.
Input: Submit an empty form.
Expected Output: Name is required.

Q26. Redirect /old-route to /new-route in Flask.
Input: Access /old-route.
Expected Output: Redirect to /new-route.

Q27. Create a REST API with basic authentication.
Input: Access API with valid credentials.
Expected Output: {"status": "success"}

Q28. Store a user’s name in the session and display it on /profile.
Input: Log in as Alice and access /profile.
Expected Output: Welcome, Alice

Q29. Add a custom middleware in Django to log incoming requests.
Input: Access /any-path/.
Expected Output: Log entry in the console.

Q30. Write a script to deploy your Flask/Django app locally.
Input: Run the server.
Expected Output: App is accessible on http://127.0.0.1:5000 or 8000.

Social Share

Bikki Singh Instructor TechnoVlogs

Bikki Singh

Hi, I am the instructor of TechnoVlogs. I have a strong love for programming and enjoy teaching through practical examples. I made this site to help people improve their coding skills by solving real-world problems. With years of experience, my goal is to make learning programming easy and fun for everyone. Let's learn and grow together!