Posts

Showing posts from May, 2023

Hosting Task Manager App in PythonAnywhere: Step-by-Step Guide

  Introduction: Hosting your web application on a reliable platform is crucial to make it accessible to users worldwide. PythonAnywhere is a popular platform that allows you to deploy and run Python applications in the cloud. In this tutorial, we will walk through the process of hosting a Task Manager app on PythonAnywhere. We will cover the following steps: Add a New Web App: Navigate to the PythonAnywhere dashboard and log in to your account. Click on the "Web" tab and then click "Add a new web app" to create a new application. Add Python Code in /home/ziaasp/mysite/flask_app.py: In the "Code" section of the PythonAnywhere dashboard, click on the "Go to Directory" link for the newly created web app. Inside the web app directory, create a new file called flask_app.py . Copy and paste your Flask application code into flask_app.py . Make sure to include all the necessary dependencies and routes. Create a New Folder Called "templates" and...

From Beginner to Intermediate: Exploring Flask's Features with a Task Manager App

Image
  Here's an example of an intermediate-level Flask app that incorporates more features and functionality: python Copy code from flask import Flask, render_template, request, redirect, url_for app = Flask(__name__) # Sample data tasks = [] @app.route( '/' ) def index (): return render_template( 'index.html' , tasks=tasks) @app.route( '/add' , methods=[ 'POST' ] ) def add_task (): task = request.form[ 'task' ] tasks.append(task) return redirect(url_for( 'index' )) @app.route( '/delete/<int:task_id>' ) def delete_task ( task_id ): if task_id < len (tasks): del tasks[task_id] return redirect(url_for( 'index' )) if __name__ == '__main__' : app.run(debug= True ) In this example, we have an app that allows users to add and delete tasks. Here's an overview of the functionality: The index() function renders the index.html template and passes the tas...