Years ago, anthropologist Margaret Mead was asked by a student what she considered to be the first sign of civilization in a culture. The student expected Mead to talk about fishhooks or clay pots or grinding stones.
No, Mead said that the first sign of civilization in an ancient culture was a femur (thighbone) that had been broken and then healed. Mead explained that in the animal kingdom, if you break your leg, you die.
You cannot run from danger, get to the river for a drink or hunt for food. You are meat for prowling beasts. No animal survives a broken leg long enough for the bone to heal.
A broken femur that has healed is evidence that someone has taken time to stay with the one who fell, has bound up the wound, has carried the person to safety and has tended the person through recovery.
“Helping someone else through difficulty is where civilization starts”, Mead said.
When I first heard about the Eco Park 7 Wonders of the World Night Tour, I was skeptical. I thought it was just a gimmick to attract visitors. But after actually experiencing it, I can confidently say that it was a truly unforgettable experience.
Seeing the scaled versions of the 7 wonders of the world at night was a different and more magical experience. The lighting and ambiance added to the grandeur of the structures, making it a sight to behold.
If you’re planning a trip to Kolkata, I highly recommend checking out the Eco Park 7 Wonders of the World Night Tour. And don’t forget to watch our video log of the experience on our KolkataDiaries YouTube channel. Trust me, you won’t regret it!
To include optional installation capabilities in your Python module’s setup.py file, you can use the extras_require parameter. The extras_require parameter allows you to define groups of optional dependencies that users can install by specifying an extra name when running pip install.
from setuptools import setup, find_packages
description='My awesome module',
# Required dependencies go here
# Optional dependencies for testing go here
In this example, the install_requires parameter lists the required dependencies for your module, which are required for installation regardless of which optional dependency groups are installed.
The extras_require parameter defines an optional dependency group called test, which includes the pytest and coverage packages. Users can install these packages by running pip install mymodule[test].
One can define multiple optional dependency groups by adding additional keys to the extras_require dictionary.
Using optional dependencies with the extras_require parameter in your Python module’s setup.py file has several advantages:
It allows users to install only the dependencies they need: By defining optional dependency groups, users can choose which additional dependencies to install based on their needs. This can help to reduce the amount of disk space used and minimize potential conflicts between packages.
It makes your module more flexible: By offering optional dependency groups, your module becomes more flexible and can be used in a wider range of contexts. Users can customize their installation to fit their needs, which can improve the overall user experience.
It simplifies dependency management: By clearly defining which dependencies are required and which are optional, you can simplify dependency management for your module. This can make it easier for users to understand what they need to install and help to prevent dependency-related issues.
It can improve module performance: By offering optional dependencies, you can optimize your module’s performance for different use cases. For example, you can include additional packages for visualization or data processing that are only needed in certain scenarios. This can help to improve performance and reduce memory usage for users who don’t need these features.
Warren Buffet, a renowned investor and business magnate, highlighted the fascinating story of the collapse of Long Term Capital Management (LTCM), a firm managed by a group of highly intelligent individuals with vast experience in the field.
Despite their exceptional intelligence and expertise, the firm’s excess leverage misfired in the opposite direction, leading to its downfall. Buffet raises the question of why smart people sometimes make foolish decisions when it comes to financial risk-taking.
He argues that risking something that is important to you for something unimportant is just plain foolish, no matter how favorable the odds may seem.
You should read about the story of Long Term Capital Management. The firm was run by a bunch of ethical super smart guys with very high IQ. The company went belly up because their excess leverage misfired in the opposite direction.” If you take John Meriwether, Eric Rosenfeld, Larry Hilibrand, Greg Hawkins, Victor Haghani and the Nobel prize winner Myron Scholes.
If you take the 16 of them, they probably have the highest average IQ of any 16 people working together in one business in the country, including Microsoft or whoever you want to name so incredible is the amount of intellect in that room. Now if you combine that with the fact that those 16 have had extensive experience in the field in which they operate.
I mean, this is not a bunch of guys who made their money selling men’s clothing and all of the sudden went to the security business or anything. They had, in aggregate, probably 350 or 400 years of experience doing exactly what they were doing. And then you throw in the third factor: that most of them had virtually all of their very substantial net worth in the business. They have their own money tied up, hundreds of hundred of millions of dollars of their own money tied up, a super high intellect, they were working in a field they knew, and they went broke. And that to me is absolutely fascinating. If I write a book, it’s going to be called “Why do smart people do dumb things?
To make the money they didn’t have and they didn’t need, they risked what they did have and did need that’s foolish, that’s just plain foolish. If you risk something that is important to you for something that is unimportant to you, it just does not make any sense. I don’t care whether the odds are 100 to 1 that you succeed, or 1,000 to 1 that you succeed.
If you hand me a gun with a thousand chambers or a million chambers, and there is a bullet in one chamber and you said ‘put it to your temple and pull it’, I’m not going to pull it. You can name any sum you want. It doesn’t do anything for me on the upside, and I think the downsize is fairly clear.
I’m not interested in that kind of a game, and yet people do it financially without thinking about it very much. It’s like Henry Kauffman said the other day– the people going broke in these situations are just two types: the ones who know nothing, and the ones who know everything.
Are you tired of encountering memory corruption errors on your Raspberry Pi due to the system running continuously for extended periods? Don’t worry; the solution is here! By using the Linux cron system, you can schedule your Raspberry Pi to reboot at set intervals, such as once a week or every day.
What is the cron system, you may ask? Cron is a time-based job scheduler in Unix-like operating systems. It enables users to schedule jobs, commands, or scripts to run automatically at specified times or intervals. Cron uses a crontab file to schedule tasks. A crontab file is a simple text file that contains a list of commands meant to be run at specified times.
So how do you use cron to schedule a reboot of your Raspberry Pi? It’s pretty straightforward. First, open a terminal on your Raspberry Pi and type the following command:
This command will open the crontab file in the default editor. If you’ve never edited your crontab file before, you’ll be prompted to choose your preferred editor.
Once the crontab file is open, you can add a new line that specifies when you want your Raspberry Pi to reboot. For example, to reboot your Raspberry Pi every day at 2:03 pm, you can add the following line:
03 14 * * * /sbin/shutdown -r now
The line above consists of five fields separated by spaces. The first two fields represent the minute and hour when you want the command to run. The third field represents the day of the month, the fourth represents the month, and the fifth represents the day of the week. In the example above, the “*” symbol means that the command should run every day of the month and every day of the week.
The final part of the line specifies the command to run, which is “/sbin/shutdown -r now” in this case. This command will reboot your Raspberry Pi immediately.
Once you’ve added the line to your crontab file, save and exit the file. Cron will automatically run the command at the specified intervals, and your Raspberry Pi will reboot accordingly.
If you’re experiencing memory corruption or other errors on your Raspberry Pi due to running continuously for extended periods, you can use the Linux cron system to schedule regular reboots.
By adding this simple line to my crontab file, I have scheduled my Raspberry Pi to reboot automatically, ensuring it runs smoothly and efficiently.
Resistance to change is a common phenomenon that affects individuals in our personal and professional lives. Despite the benefits that change can bring, we often find it challenging to embrace new ideas, habits, or practices.
This resistance to change can be attributed to a variety of factors, including fear of the unknown, a preference for the familiar, and a desire to maintain the status quo. As a result, as individuals we resist change in various aspects of our lives, from trying new foods to adopting new technologies or changing careers.
The following story of seat belts exemplifies how change, despite being a constant aspect of life, often takes a long time to integrate into our daily routines.
Thirty-seven thousand Americans died in car accidents in 1955, six times today’s rate adjusted for miles driven.
Ford began offering seat belts in every model that year. It was a $27 upgrade, equivalent to about $190 today. Research showed they reduced traffic fatalities by nearly 70%.
But only 2% of customers opted for the upgrade. Ninety-eight percent of buyers chose to remain at the mercy of inertia.
Things eventually changed, but it took decades. Seatbelt usage was still under 15% in the early 1980s. It didn’t exceed 80% until the early 2000s – almost half a century after Ford offered them in all cars.
It’s easy to underestimate how social norms stall change, even when the change is an obvious improvement. One of the strongest forces in the world is the urge to keep doing things as you’ve always done them, because people don’t like to be told they’ve been doing things wrong. Change eventually comes, but agonizingly slower than you might assume.
In “The Psychology of Money,” author Morgan Housel discusses the power of compounding and how it applies not just to money, but also to other areas of our lives such as careers and relationships. Compounding is the process of earning interest on your interest, which can lead to exponential growth over time. However, compounding requires time and patience, as it works best over years or decades.
When it comes to our finances, compounding is a powerful tool for building wealth. By starting to save and invest early and consistently, we can harness the power of compounding and watch our savings grow exponentially over time. However, this requires endurance and a long-term perspective. We must be willing to stick to our savings plan even when it may seem difficult or tempting to deviate from it.
But compounding is not just about money. It also applies to our careers and relationships. Just as a small amount of money can grow into a large sum over time, small actions taken consistently in our careers and relationships can lead to significant growth and progress.
Endurance is key in both our financial and personal lives. We must be willing to stick with our goals and plans even when it feels challenging or uncomfortable. This requires a long-term perspective and the willingness to delay gratification in the short term in order to achieve our long-term goals.
Another important aspect of endurance is balance. As Housel notes, we are constantly changing over time, and what we value and prioritize can shift. Therefore, it is important to maintain balance in our lives at every point in time. This means taking care of our physical, emotional, and mental health, as well as nurturing our relationships and pursuing our passions and interests. By maintaining balance, we can avoid future regret and encourage endurance in all areas of our lives.
Endurance and balance are key components in harnessing the power of compounding in all areas of our lives. By maintaining a long-term perspective and taking consistent, small actions, we can achieve significant growth and progress over time.
Compounding works best when you can give a plan years or decades to grow. This is true for not only savings but careers and relationships. Endurance is key. And when you consider our tendency to change who we are over time, balance at every point in your life becomes a strategy to avoid future regret and encourage endurance.
Are you tired of manually checking your Raspberry Pi’s disk space and latest files? With a few lines of Python code and the Flask web framework, you can create a simple application that monitors your Raspberry Pi for you.
In this post, we will walk through the code that monitors the free disk space on your Raspberry Pi and returns the latest modified file in a specified folder.
To get started, we need to install the Flask and psutil libraries.
Once you have the dependencies installed, create a new Python file and copy the following code:
First, we import the Flask, os, and psutil libraries. Flask is the web framework that we will use to create the application. The os library provides a way to interact with the Raspberry Pi’s file system. Psutil is a cross-platform library for retrieving system information.
Next, we create a new Flask application instance and define two routes: /disk-space and /file.
The /disk-space route uses the psutil library to obtain the amount of free disk space on the Raspberry Pi’s root file system (“/”). The value is converted to megabytes and returned as a string.
The /file route lists all files in the specified folder (in this case, the “Documents” folder in the Raspberry Pi user’s home directory) and returns the name of the most recently modified file. The files are sorted based on their modification time using os.path.getmtime.
Finally, we start the Flask application on port 8989.
To run this application on your Raspberry Pi, save the code to a file (e.g. app.py) and run the following command:
I recently came across a wonderful story from the book “All I Want To Know Is Where I’m Going To Die So I’ll Never Go There: Buffett & Munger – A Study in Simplicity and Uncommon, Common Sense” by Peter Bevelin that really struck a chord with me.
The story is about a little boy in Texas who was asked a simple arithmetic question by his teacher. The question was, “If there are 9 sheep in the pen and one jumps out, how many are left?”
The other children in the class got the answer right, but the little boy had a different response. He said, “None of them are left.”
The teacher, thinking that the boy didn’t understand arithmetic, corrected him and said, “You don’t understand arithmetic.”
But the little boy replied, “No teacher. You don’t understand sheep.”
The little boy’s response was very insightful. Sheep are known to move in herds and follow each other blindly. If one sheep strays from the path, the others will follow, and none will be left behind. This is why shepherds carry sticks – to keep the sheep on the right track.
The little boy understood the nature of sheep and knew that if one sheep jumps out, all the others would follow. Therefore, none would be left in the pen.
We often think we know everything about a particular subject or situation, but sometimes we don’t. It’s important to step back and examine things from different angles and perspectives, like the little boy did with the sheep.
Have you ever encountered a scenario where you were testing a Python app in a new environment, only to find that there was a missing package that you couldn’t install without help from IT? Recently, I ran into this issue myself and wanted to share my experience.
When faced with a missing package that can only be installed by IT, you may still want to migrate and run pytest on ported code. However, you may find that pytest fails during the collections stage, preventing you from proceeding with your testing. This is certainly not ideal, but fortunately, there’s an easy solution to this problem.
To avoid aborting test collection on import errors (or any other errors), simply use the “–continue-on-collection-errors” flag. This flag tells pytest to continue running even if it encounters errors during the collection phase.
Additionally, you can skip tests on a missing import by using “pytest.importorskip” at the module level, within a test, or test setup function. For example, you can skip a test that relies on a missing “docutils” package with the following line of code:
docutils = pytest.importorskip("docutils")
This allows you to skip tests that depend on a package that cannot be installed or imported, without affecting the rest of your test suite.
In conclusion, encountering a missing package during testing can be frustrating, but it doesn’t have to derail your progress. By using the right flags and skipping tests as necessary, you can continue testing your Python app in a new environment even if there are missing dependencies.
Author William Dawson wrote in his book The Quest for The Simple Life in 1905 that the hardest thing to understand about money is the thrill of the chase. According to Dawson, something you can easily afford brings less joy than something you must save and struggle for.
Dawson went on to say, “The man who can buy anything he covets values nothing that he buys.” This statement holds true even today, as we can see in our own lives and with our children.
If we attend to our children’s every whim and fancy without delay or consideration, we have seen that they value those things less. The same goes for us as adults – we could have bought the car we wanted a long time ago, but we know that if we had, we would not have enjoyed it as much as we do now. The delay and the time spent getting it has increased its value by many folds.
Many of us know someone who is constantly pampering their children in the name of love, but the children don’t seem to value the things they get. When questioned, the parents defend their actions by saying, “It’s just a matter of a few bucks,” or “Oh, he/she has reduced this habit now; it’s just some small thing.”
It’s appalling to see this behavior, but often we drop the case without taking any action.
Delayed gratification can make things more valuable and enjoyable. As parents, we should teach our children the value of hard work and delayed gratification, and as individuals, we should practice it ourselves.
Have you ever heard of a car that wouldn’t start after buying a particular flavor of ice cream? It sounds like a silly problem, but that was exactly what happened to one lucky Ford owner who had a family tradition of sending him to buy ice cream each night. Every time he bought vanilla ice cream, his Ford wouldn’t start, but if he got any other flavor, the car would start just fine. This led to a peculiar question – why was his car “allergic” to vanilla ice cream?
To uncover the truth, Ford asked the owner, Fred, to carefully document his next four nights of buying ice cream. The results were intriguing – when Fred chose vanilla, the car wouldn’t start, but with any other flavor, the car started promptly. So what was the cause of this strange phenomenon?
Ford sent an engineer to the store to investigate further, and the results were surprising. It turned out that vanilla was the most popular flavor, and it was kept in a separate case at the front of the store for quick pick-up. All the other flavors were kept in the back of the store, and it took considerably longer to get served. This key difference in time was the root cause of the problem – the extra time needed to get other flavors allowed the engine to cool down sufficiently to start, while the quicker purchase of vanilla kept the engine too hot, causing vapor lock.
The solution was simple – Fred just needed to wait a few extra minutes after shutting off the engine before restarting the car. This allowed the engine to cool down and the vapor lock to dissipate.
This story serves as a valuable lesson about problem-solving. Sometimes, our initial interpretation of the solution to a problem may not make logical sense, and it’s important to search for alternative solutions. In this case, refining and testing the hypothesis, digging deeper, and gathering data were the key to uncovering the truth and solving the problem.
Are you tired of staring at the same old desktop background on your Windows laptop every day? Do you have a collection of beautiful travel pictures that you’d love to see on your screen instead? If you answered yes to both of these questions, then you’re in luck! In this post, I’ll show you how to create a Python script that changes your desktop background every 15 minutes using your favorite travel photos. I have done the same for my office laptop.
First, create a new folder on your laptop called “pics” and add your favorite travel pictures to it. You can use images from your own travels or download high-quality images from website of your choice.
Next, let’s create the Python script that will change your desktop background. Open up your favorite text editor and create a new file called “change_background.py”. Then, copy and paste the following code:
from random import choice
event_schedule = sched.scheduler(time.time, time.sleep)
SPI_SETDESKWALLPAPER = 20
FILES = [os.path.join(FOLDER, f) for f in os.listdir(FOLDER)]
event_schedule.enter(choice([13,23,7,11,5])*60, 1, change_wallpaper, ())
if __name__ == "__main__":
event_schedule.enter(10, 1, change_wallpaper, ())
Make sure to replace “FOLDER” with your actual path of your images.
This code uses the “ctypes” module to call the “SystemParametersInfoW” function from the Windows API, which changes the desktop background to a random image from the “pics” folder. The script then waits for random minutes before changing the background again.
Save the file and make sure it is in a directory that you can easily access. Now, let’s schedule the script to run automatically every time you start your laptop.
Open up the Windows Task Scheduler by searching for it in the Start menu. Click on “Create Basic Task” and follow the prompts to set up a new task.
When prompted to choose a program/script, browse to the location of your “change_background.py” file and select it. Set the trigger to “At Startup” and click “Finish” to complete the setup.
Now, every time you start your laptop, your Python script will automatically run in the background and change your desktop background every 15 minutes.
In conclusion, with just a few lines of Python code and the Windows Task Scheduler, you can turn your boring desktop background into a slideshow of your favorite travel photos. Give it a try and let me know how it goes!
The integration of AI, robotics, and quantum computing into our lives has been a topic of much discussion and speculation. However, rather than viewing these technological advancements as a threat, we should see them as a way to enhance and augment our capabilities.
History has shown us the power of man and machine working together, as exemplified by Wilbur Wright’s story of innovation in flight. Just as aviation is no longer considered “artificial” flight, we should view technological intelligence as an extension of human intelligence.
Recently read this in the book “hit refresh” by Satya Nadella
AI, robotics, and even quantum computing will simply be the latest examples of machines that can work in concert with people to achieve something greater.
Historian David McCullough has told the story of Wilbur Wright, the bike mechanic and innovator of heavier-than-air flight at the turn of the last century. McCullough describes how Wilbur used everything he could humanly muster—his mind, body, and soul—to coax his gliding machine into flight. The grainy old film, shot from a distance, fails to capture his grit and determination. But if we could zoom in, we’d see his muscles tense, his mind focus, and the very spirit of innovation flow as man and machine soared into the air for the first time, together.
When history was made at Kitty Hawk, it was man with machine—not man against machine.
Today we don’t think of aviation as “artificial flight”—it’s simply flight. In the same way, we shouldn’t think of technological intelligence as artificial, but rather as intelligence that serves to augment human capabilities and capacities
Battery percentage is an important aspect of mobile devices, laptops, and other battery-powered electronic devices. It tells us how much energy the battery has , which is crucial in determining how long the device will last before needing to be recharged.
In this blog post, we will see how to get battery percent information in Windows using Python.
Using the psutil Library
The psutil library is a comprehensive library for retrieving information about the system and processes running on it. It provides a simple and straightforward way to access the battery percent information in Windows.
Here is an example code that demonstrates how to use psutil to get the battery percent information in Windows:
In the code above, we first import the psutil library. Then, we use the sensors_battery() function to get the battery capacity information.
This function returns a sensors_battery object, which contains several properties that provide information about the battery, such as the percent, power plugged, and others. In the above example, we print the percent of the battery.
Despite a year of mixed feelings, I managed to find time to delve into some fascinating reads. Due to the pandemic, my usual reading habits were disrupted, as most of my reading would typically take place during my daily commute. However, in 2022 the addition of new distractions at home caused me to read even fewer books. At one point during the year, I was reading just one book a month.
However, a bright spot in the year was a long-awaited train journey, which allowed me to read a few fiction novels and reignite my love for reading fiction.
Cooked: A Natural History of Transformation by Michael Pollan: This book explores the transformative power of cooking and its impact on both our culture and our biology.
The CEO Factory: Management Lessons from Hindustan Unilever by Sudhir Sitapati: This book examines the management strategies and principles used by Hindustan Unilever, one of India’s largest consumer goods companies, and outlines the key lessons that can be learned from their success.
Elemental by Tim James: This book delves into the elemental forces of nature and the impact they have on our lives, offering a unique perspective on the world around us.
Influence by Robert B. Cialdini: This book provides insights into the psychology of influence, exploring the tactics and strategies used by people to persuade others and how these can be applied in business, marketing, and everyday life.
Money Wise: Timeless Lessons for Building Wealth by Deepak Cheney: This book offers practical advice on how to grow and manage wealth, using timeless lessons from history and the experiences of successful investors.
You Look Like a Thing and I Love You by Janelle Shane: This book explores the cutting-edge world of AI and machine learning, showcasing how these technologies are transforming the way we live, work, and think.
The Secret History of Food: Strange but True Stories About the Origins of Everything We Eat by Matt Siegel: This book takes a fascinating look at the history of food, uncovering the surprising origins of many of our favorite dishes and exploring the cultural and economic forces that shape our food choices.
Bulls, Bears and Other Beasts by Santosh Nair: This book provides a humorous and insightful look at the world of stock trading and investment, exploring the often-bizarre behaviors of traders and the underlying reasons for their success or failure.
Space Case by Stuart Gibbs: This is a science fiction novel set in the future, exploring the adventures of a group of astronauts on a mission to explore a distant planet.
Idiot Brain by Dean Burnett: This book provides a humorous and insightful look at the science of the human brain, exploring the reasons why we make the decisions we do and how we can use this understanding to improve our lives.
Subscribed: Why the Subscription Model Will Be Your Company’s Future – and What to Do About It by Tien Tzuo and Gabe Weisert: This book explores the rise of the subscription business model and its impact on the future of commerce, offering insights and strategies for companies looking to embrace this new way of doing business.
Maths on the Back of an Envelope: Clever Ways to (Roughly) Calculate Anything by Rob Eastaway: This book provides a practical and entertaining guide to using math to solve everyday problems, using simple and intuitive methods to make quick and accurate calculations.
Evolution gone wrong: the curious reasons why our bodies work or don’t by Alex Bezzerides: This book provides a humorous and insightful look at the science of human evolution, exploring the ways in which our bodies have adapted to our environment and the surprising ways in which they sometimes go wrong.
Making Numbers Count by Chip Heath and Karla Starr: This book provides a practical guide to using data and statistics to drive business decisions, offering tips and insights for improving data analysis and interpretation.
How Innovation Works by Matt Ridley: This book provides a comprehensive overview of the science and economics of innovation, exploring the history and future of technological progress and its impact on society.
Cracking the Code: My Journey in Bollywood by Ayushmann Khurrana and Tahira Kashyap is a memoir about the journey of the Bollywood actor, Ayushmann Khurrana, and his rise to fame. The book offers a behind-the-scenes look at the challenges and obstacles he faced along the way, as well as the strategies he used to overcome them.
Around the Corner to Around the World by Robert Rosenberg is a book about key lessons from Dunkin’ Donuts former CEO Robert Rosenberg that offer critical insights and a unique, 360-degree perspective to business leaders and managers on building one of the world’s most recognized brands.
The Physics of Everyday Things by James Kakalios is a science book that explores the underlying principles of physics that govern the objects and events we encounter in our daily lives. The author provides an accessible and engaging look at topics such as motion, energy, and forces.
Antifragile: Things That Gain From Disorder by Nassim Nicholas Taleb is a book that explores the concept of antifragility, which refers to the ability of some systems to thrive in the face of chaos and uncertainty. The author argues that antifragility is a key factor in creating resilience and success in life and business.
Tick Tock by Simon Mayo is an Exciting and urgently contemporary novel, which tells the story of a global catastrophe through the eyes of the three people at the heart of the storm.
Lost in Time by A.G. Riddle is a thrilling science fiction novel that takes you on a journey 200 million years into the past. The protagonist, a scientist, embarks on this journey to save his daughter who has been wrongly accused of murder. However, as he delves deeper into the past, he realizes that there are secrets that are waiting for him. With more than just his daughter’s life at stake, this book will leave you on the edge of your seat as you witness the scientist’s quest to save his loved one and uncover the truth behind these secrets.
The Loop by Ben Oliver is a science fiction novel that depicts life inside a futuristic death row for minors under the age of 18 as a never-ending cycle of purgatory. However, when the inmates become aware of the unrest and turmoil in the outside world and disorder begins to unfold, their confinement in the prison becomes the least of their concerns.
The Strategic Dividend Investor by Daniel Peris is a book about investing in dividend-paying stocks. The author provides practical advice on how to identify and select high-quality dividend stocks, and how to construct a diversified portfolio that can generate consistent income and long-term growth.
My search for a fiction writer to replace Michael Crichton continues, specifically in the genre of science fiction. If you have any suggestions, please let me know.
My Django learning app deployed on raspberrypi for kids was functioning smoothly when accessed from a home network. However, when we had to travel to Kolkata, and the app was promoted to a PythonAnywhere server. This move brought about a new challenge, as the app started to face issues with Cross-Origin Resource Sharing (CORS).
I soon realized that this was a common issue and could be easily resolved by enabling CORS in the Django app.
I followed the following simple process and soon had the app up and running smoothly again, with CORS enabled. The end.
Here’s how to enable CORS in Django:
Install the Django-Cors-Headers package by running python -m pip install Django-cors-headers
Add it to the INSTALLED_APPS list in your Django settings:
INSTALLED_APPS = [ ... 'corsheaders', ...]
Add the CorsMiddleware class to the MIDDLEWARE list: