diff --git a/Days-27-30.md b/Days-27-30.md deleted file mode 100644 index 2914dfc..0000000 --- a/Days-27-30.md +++ /dev/null @@ -1,94 +0,0 @@ -### **Day 27: Introduction to Web Development** -Web development involves creating websites and web applications. Python can be used for web development with the help of web frameworks like Flask or Django. - -- **Understanding Web Development:** - - Web development involves designing and building websites or web applications that are accessible through web browsers. - - It encompasses both the front-end (user interface) and back-end (server-side) development. - -### **Day 28: Flask - Creating a Basic Web Application** -Flask is a lightweight web framework for Python. You can create a basic web application with Flask. - -- **Getting Started with Flask:** - - Install Flask using `pip install flask`. - - Create a Flask application and define routes. - - Use decorators like `@app.route('/')` to map URLs to view functions. - - Start the development server using `app.run()`. - -**Example of a basic Flask web application:** -```python -from flask import Flask - -app = Flask(__name__) - -@app.route('/') -def hello_world(): - return 'Hello, World!' - -if __name__ == '__main__': - app.run() -``` - -### **Day 29: Flask - Adding Routes and Templates** -Flask uses routes to map URLs to view functions. You can use templates to generate dynamic HTML content. - -- **Adding Routes and Templates:** - - Define multiple routes for different URLs. - - Use the `render_template` function to render HTML templates. - - Pass data from the view function to the template. - -**Example of adding routes and using templates in Flask:** -```python -from flask import Flask, render_template - -app = Flask(__name__) - -@app.route('/') -def index(): - return 'Home Page' - -@app.route('/about') -def about(): - return 'About Us' - -@app.route('/contact') -def contact(): - return 'Contact Us' - -@app.route('/profile/') -def profile(username): - return render_template('profile.html', username=username) - -if __name__ == '__main__': - app.run() -``` - -### **Day 30: Flask - Handling Forms and Data** -Web applications often require handling user input through forms. You can use Flask to create forms and handle form data. - -- **Handling Forms in Flask:** - - Create HTML forms with input fields. - - Use the `request` object in Flask to access form data. - - Handle form submissions and process user input. - -**Example of handling forms in Flask:** -```python -from flask import Flask, render_template, request - -app = Flask(__name__) - -@app.route('/') -def index(): - return render_template('index.html') - -@app.route('/submit', methods=['POST']) -def submit(): - if request.method == 'POST': - name = request.form['name'] - email = request.form['email'] - return f'Thank you, {name}, for submitting your email: {email}' - -if __name__ == '__main__': - app.run() -``` - -Web development is a vast field, and Flask is an excellent starting point for building web applications with Python. However, for more extensive and feature-rich applications, you may consider learning Django, another popular Python web framework. These examples provide a foundation for creating web applications and handling user interactions using Flask. You can continue to explore and expand your web development skills from here. \ No newline at end of file