DigitalOcean Referral Badge
Udit Vashisht
Author: Udit Vashisht


How to host and schedule your python script on PythonAnywhere?

PythonAnywhere पर अपनी Python स्क्रिप्ट को होस्ट और शेड्यूल कैसे करें?

  • 2 minutes read
  • 1154 Views
How to host and schedule your python script on PythonAnywhere?

    Table of Contents

In our last post here, we learned how to create a python script which will automatically delete your messages from gmail account based on a query.

The complete ready-to-use code can be found here.

Follow the steps in the above tutorial to download the ‘credentials.json’ file and then run the init() method to create the ‘token.json’ file, as we will be needing both of them for hosting our script on PythonAnywhere.

If you don’t already have an account on PythonAnywhere create one and choose the ‘Beginner Account’ at signup as it is free.

host_python_script_on_pythonanywhere_for_free_in_hindi.png

Once you have signed up and verified your account. Go to ‘Files’, select ‘Upload a file’ and upload ‘credentials.json’, ‘token.json’ and ‘auto_delete.py’. Make sure to add your desired query in the last part of the script:-

if __name__ == '__main__':
    logger.info("Deleting messages from abc@gmail.com.")
    delete_messages('from:abc@gmail.com\
            subject:"Go Shopping"\
            older_than:1d'
                    )

host_python_script_on_pythonanywhere_for_free_in_hindi_2.png

Now, select tasks and give the path of ‘auto_delete.py’ file, if your are following this tutorial, the path will be

/home/**yourusername**/auto_delete.py

Select a time when you want the script to run. For the very beginning, you can set it 2-3 minutes later than current time to check if there is any error log or something.

host_python_script_on_pythonanywhere_for_free_in_hindi_3.png

If there are no errors, then you are good to go. Also, in addition to the log created by PythonAnywhere, one more file name ‘auto_delete.log’ will be created in your home folder which will have all your logged message.

In the beginner account you can only have one scheduled script, if you want this same script to run more than one time in a day you have to opt for paid plans on PythonAnywhere.

In case of any issues, feel free to ask in the comment section.


Related Posts

How to create a Telegram Bot using Python?
By Udit Vashisht

Create a Telegram Bot using Python

In this article, we will learn to create a simple telegram bot using python. First of all, we will create the API token for our telegram bot.

Connect with FatherBot

We can do this by opening the BotFather bot on telegram. Yes, we ...

Read More
Venv Python - A complete tutorial on Virtual Environments in Python
By Udit Vashisht

What is Virtual Environment in Python ?

Virtual Environment is a kind of a container which runs specific version of Python and its modules. And it is used in the cases where you are working on two different project which has different dependencies. Say one of your project uses Django ...

Read More
Chapter 5- Indentation
By Udit Vashisht

What is indentation in Python?

Like many other languages, python is also a block-structured language.

Blocks of code in Python

Block is basically a group of statements in a code script. A block in itself can have another block or blocks, hence making it a nested block. Now, ...

Read More
Search
Tags
tech tutorials automate python beautifulsoup web scrapping webscrapping bs4 Strip Python3 programming Pythonanywhere free Online Hosting hindi til github today i learned Windows Installations Installation Learn Python in Hindi Python Tutorials Beginners macos installation guide linux SaralGyaan Saral Gyaan json in python JSON to CSV Convert json to csv python in hindi convert json csv in python remove background python mini projects background removal remove.bg tweepy Django Django tutorials Django for beginners Django Free tutorials Proxy Models User Models AbstractUser UserModel convert json to csv python json to csv python Variables Python cheats Quick tips == and is f string in python f-strings pep-498 formatting in python python f string smtplib python send email with attachment python send email automated emails python python send email gmail automated email sending passwords secrets environment variables if name == main Matplotlib tutorial Matplotlib lists pandas Scatter Plot Time Series Data Live plots Matplotlib Subplots Matplotlib Candlesticks plots Tutorial Logging unittest testing python test Object Oriented Programming Python OOP Database Database Migration Python 3.8 Walrus Operator Data Analysis Pandas Dataframe Pandas Series Dataframe index pandas index python pandas tutorial python pandas python pandas dataframe python f-strings padding how to flatten a nested json nested json to csv json to csv python pandas Pandas Tutorial insert rows pandas pandas append list line charts line plots in python Django proxy user model django custom user model django user model matplotlib marker size pytplot legends scatter plot python pandas python virtual environment virtualenv venv python python venv virtual environment in python python decorators bioinformatics fastafiles Fasta python list append append raspberry pi editor cron crontab Cowin Cowin api python dictionary Python basics dictionary python list list ios development listview navigationview swiftui ios mvvm swift environmentobject property wrapper @State @Environm popup @State ios15 alert automation instagram instaloader texteditor youtubeshorts textfield multi-line star rating reusable swift selenium selenium driver requests-html youtube youtube shorts python automation python tutorial algo trading nifty 50 nifty50 stock list nifty50 telegram telegram bot dictionary in Python how to learn python learn python