Giter Club home page Giter Club logo

recipes's Introduction

Flask/MySQL Setup

Clone this repo

git clone https://github.com/cmderobertis/flask_template.git

Install Flask and PyMySQL

  • The Pipfiles are pre-configured, so just run the command below to install both Flask and PyMySQL.
pipenv install

Modify template files accordingly

  • This may need to be modified depending on the frameworks or Operating System you're using.
  • When in doubt, generate a new gitignore file on Gitignore.io.
  • Change this filename (and 'database_name' on line 19) to the name of your database.

  • Have a copy of the 'ClassName' class for each table in your database. If you have 3 tables total, you'll have 3 classes total.

  • Repeat the following steps for each table:

    1. Change 'ClassName' to your table name (in PascalCase, singular).
    2. Update the __init__ method to reflect the columns present in your table.
    3. Replace all instances of 'friends' with your table name.
    4. Replace all instances of 'friend' with your table name, singular.
  • If everything goes well, you'll have a class for each table in your database, named after that table, with attributes corresponding to the columns present in your table. Neat!

  • In the 'connect' method on line 7, update the user and password to reflect your MySQL connection settings.
  • Line 2: Replace 'ClassName' and other classes in the import statement with the classes from your database_name.py file.
  • Replace all instances of 'friends' with a table name (in snake_case, plural).
  • Line 10: Change 'ClassName' to your table name (in PascalCase, singular).
  • Note that the code referenced in the previous two steps are meant to test the connection with the database. Feel free to modify your '/' route after running the server without error.

Test the server

Run the following:

pipenv shell
python3 server.py

If the server is running without error, visit your Localhost to check it out. Congratulations, you've just created a full-stack web application!

recipes's People

Contributors

cmderobertis avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.