Skip to content

Demo for a Python website using Flask as a framework and MySQL as a database

License

Notifications You must be signed in to change notification settings

amitojsingh366/python-flask-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Flask Demo

This Repo should help you to get a simple Python website setup using the Flask framework and MySQL as a database

To-Do

  • Preparing for the Project

    • First ensure Python is installed
      • Run the command in Command Prompt (or any other shell) python --version
      • If not installed get it from here
    • Enure MySQL Community Edition Is Installed
      • Search For MySQL Command Line Client (It looks like this)
      • If not installed get it from here
    • Ensure An IDE is installed (I have given popular ones below)

Setting Up The Test Project

  • Ensure steps in To-Do are completed

  • Run the commands in Useful Stuff

  • Downloading the test project code

    • Download the code from this repo
      • Code can be downloaded from here or by using the button above
      • Extract the zip file downloaded and place the extracted folder somewhere you can remember
  • Updating project settings

    • Editing the MySQL util file (util.py)
      • Change line 11 in util.py:
        • The feild password should be set to the password that you created while setting MySQL server up
          • The line should look like: connection = mysql.connector.connect(host="localhost", database="demo", user="root", password="YOUR_PASSWORD_HERE", auth_plugin='mysql_native_password')
  • Running The Server

    • Open your project folder in a command line
    • Run the following command to start the server
      • Open your project folder in a command line and run the following command:
        • python app.py
    • Go to the website to see the app running

Useful Stuff

  • Commands That Will Be Used

    • Python Commands:

      • Installing Flask and MySQL-Connector:
        • Run the following command to install Flask and MySQL-Connector:
          • Open your project folder in a command line and run the following command:
            • python -m pip install flask mysql-connector mysql-connector-python
    • MySQL Commands:

      • Creating a Database and setting it up:
        • Open MySQL Command Line Client (It looks like this)
        • Login Using The Password you set in setup
        • Create a database called demo using the following command:
          • CREATE DATABASE demo;
        • Select that database to perform operations on it using the following command:
          • USE demo;
        • Create a table called users in the database with the following command:
          • CREATE TABLE users (id int NOT NULL AUTO_INCREMENT, username varchar(2000), password varchar(2000), uid VARCHAR(2000), PRIMARY KEY (id));

          • This command will create a tabe called users which contains the following columns:

            Column Type Description
            id INT PRIMARY
            username VARCHAR-2000 -
            password VARCHAR-2000 -
            uid VARCHAR-2000 -
  • Useful Links

About

Demo for a Python website using Flask as a framework and MySQL as a database

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published