How to Handle HTTP Requests and Responses in Python
Make HTTP calls with the requests library and handle incoming requests in Flask and Django, with timeouts, error handling, JSON bodies and status codes.
Spread Your Knowledge. Questions with answers, tutorials and articles, newest first.
Make HTTP calls with the requests library and handle incoming requests in Flask and Django, with timeouts, error handling, JSON bodies and status codes.
A practical walkthrough of building a Python web app with Flask or Django, from setup and routes to databases, security basics and deployment.
Flask is a minimal micro-framework, Django is a full-stack framework with ORM and admin. Compare features, security, scaling and when to choose each.
A practical introduction to reinforcement learning in Python using Gymnasium, tabular Q-learning and Stable-Baselines3, with the modern reset and step API.
Train models on a few labeled and many unlabeled samples using scikit-learn's SelfTrainingClassifier and LabelSpreading, plus pseudo-labeling for neural networks.
Train models on data streams in Python using scikit-learn partial_fit, incremental scaling and test-then-train evaluation, with tips for concept drift.
Fine-tune a pre-trained image model in Python with Keras: train a new head, unfreeze the top layers and recompile with a low learning rate.
Reuse a pre-trained image model in Keras: freeze the base, train a new classification head, then fine-tune the top layers at a low learning rate.
Build a working GAN in Python with Keras 3: a generator, a discriminator and a custom training step that generates handwritten digits from MNIST.
Build dense, convolutional and denoising autoencoders in Python with Keras 3, train them on MNIST and learn what the latent bottleneck does.
Build an LSTM in Python with both Keras and PyTorch, from windowing a time series to training, evaluating and tuning the model.
Implement an RNN in Python with Keras and PyTorch, from windowed sequence data to training, with shape pitfalls and LSTM or GRU guidance.
Build, train and evaluate a CNN for image classification in Python, with complete Keras 3 and PyTorch examples on CIFAR-10.
Build, train and evaluate a feedforward neural network in Python using Keras 3 and PyTorch, with a complete Iris classification example.
Train the same neural network in PyTorch and Keras 3, learn how to evaluate it, avoid overfitting and save the model for reuse.
Keras is a high-level API that now runs on TensorFlow, JAX or PyTorch. PyTorch is a flexible framework where you write the training loop.
Learn how to persist trained models with joblib, Keras .keras files and PyTorch state_dict, and how to avoid the security and version pitfalls.
Tune machine learning models in Python with GridSearchCV, RandomizedSearchCV and Optuna, using cross-validation and pipelines to avoid data leakage.
Select the best features in Python using filter, wrapper and embedded methods in scikit-learn, with pipeline examples that avoid data leakage.
Use scikit-learn to run k-fold, stratified and time series cross-validation, avoid data leakage with pipelines and tune models with nested CV.