<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Thasethi</title>
    <description>The latest articles on DEV Community by Thasethi (@afro-affiliate).</description>
    <link>https://dev.to/afro-affiliate</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1092200%2F7c2323e1-2d3d-47d5-b7e6-cbe747e9fdad.jpg</url>
      <title>DEV Community: Thasethi</title>
      <link>https://dev.to/afro-affiliate</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/afro-affiliate"/>
    <language>en</language>
    <item>
      <title>code 501 message unsupported method ('post') python</title>
      <dc:creator>Thasethi</dc:creator>
      <pubDate>Tue, 30 May 2023 07:56:55 +0000</pubDate>
      <link>https://dev.to/afro-affiliate/code-501-message-unsupported-method-post-python-368e</link>
      <guid>https://dev.to/afro-affiliate/code-501-message-unsupported-method-post-python-368e</guid>
      <description>&lt;p&gt;Good day&lt;/p&gt;

&lt;p&gt;I am trying to make a simple login page but when I run it I get and error code "code 501 message unsupported method ('post') python" I'm using  python -m http.server 3000 for my server and I have a data base of user's in MySQL workbench. May you please assist.&lt;br&gt;
from flask import Flask, render_template, request, session, redirect&lt;br&gt;
from flask_mysqldb import MySQL&lt;br&gt;
from http.server import HTTPServer, BaseHTTPRequestHandler&lt;/p&gt;

&lt;p&gt;app = Flask(&lt;strong&gt;name&lt;/strong&gt;)&lt;br&gt;
app.secret_key = '1234'  # Set a secret key for session management&lt;/p&gt;

&lt;h1&gt;
  
  
  MySQL configuration
&lt;/h1&gt;

&lt;p&gt;app.config['MYSQL_DATABASE_HOST'] = 'localhost:3306'&lt;br&gt;
app.config['MYSQL_DATABASE_USER'] = 'root'&lt;br&gt;
app.config['MYSQL_DATABASE_PASSWORD'] = 'Core@123!'&lt;br&gt;
app.config['MYSQL_DATABASE_DB'] = 'login'&lt;br&gt;
mysql = MySQL(app)&lt;/p&gt;

&lt;p&gt;@app.route('/')&lt;br&gt;
def home():&lt;br&gt;
    return 'Welcome to the login system'&lt;/p&gt;

&lt;p&gt;@app.route('/login', methods=['GET', 'POST'])&lt;br&gt;
def login():&lt;br&gt;
    if request.method == 'POST':&lt;br&gt;
        username = request.form['username']&lt;br&gt;
        password = request.form['password']&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    cursor = mysql.connection.cursor()
    cursor.execute("SELECT * FROM users WHERE username = %s AND password = %s", (username, password))
    user = cursor.fetchone()

    if user:
        session['username'] = username
        return redirect('/dashboard')
    else:
        return 'Invalid username or password'

return render_template('login.html')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;@app.route('/dashboard')&lt;br&gt;
def dashboard():&lt;br&gt;
    if 'username' in session:&lt;br&gt;
        return 'Welcome to the dashboard, ' + session['username']&lt;br&gt;
    else:&lt;br&gt;
        return redirect('/login')&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
