Giter Site home page Giter Site logo

phillipdwright / pyp-w4-gw-twitter-clone Goto Github PK

View Code? Open in Web Editor NEW

This project forked from duddles/pyp-w4-gw-twitter-clone

0.0 2.0 0.0 67 KB

Basic web site cloning Twitter functionalities

License: Creative Commons Attribution Share Alike 4.0 International

Makefile 0.92% Python 50.87% PLSQL 2.53% CSS 0.42% HTML 45.26%

pyp-w4-gw-twitter-clone's Introduction

[pyp-w4] Twitter clone

Today's project consists on building a Twitter clone using Flask.

Setting up the database

Our data model contains just two tables (user and tweet), which are going to be stored using SQLite. You can use the file twitter-schema.sql to create your local database schema, using the following command:

$ sqlite3 twitter.db < twitter-schema.sql

Testing data

Once your database is set up, you will probably need some pre loaded data before you can start testing your app. Feel free to use SQL queries to fill both tables with information. In the twitter-schema.sql file you will see some sample queries commented out.

Note: The password field in user table is stored as the MD5 hash of the user's password. Remember to never store any password as plain text

Running the app server

Flask framework provides, out of the box, a way to run a development web server in your local machine. Just execute the runserver.py script available in the project and the application will stay listening at localhost:8080. (Make sure to have all the requirements previously installed)

$ python twitter_clone/runserver.py

Note: Your will probably need to configure the PYTHONPATH env variable to make the project work correctly.

The application

We will have three main sections in our application: authentication (log in and log out), feed and profile. The feed section will be where all the user's tweets are going to be displayed. Profile section will contain user's personal data, and will allow us to update the profile information.

Logging in

When we first visit the application, we must be redirected to the /login page so we can authenticate.

login

If the authentication fails, an error alert must be display saying that provided user or password were not correct. Otherwise, we must be redirected to the logged in user's feed.

Logged user feed

logged_feed

When visiting the feed of the logged in user we will see, in addition to the whole list of tweets, an HTML form containing a textarea element. That form will allow us to post new tweets in our feed.

You will also notice that each tweet element has a cross button on the top right corner. That button must also be wrapped inside an HTML form, and will allow us to delete one particular tweet by POSTing to /tweets/<tweet-id>/delete.

The list of tweets must be sorted by creation date in a descending order.

Other user feed

When the feed we are visiting does not belong to the logged in user, we won't see the tweet form on top of the page. Delete buttons must also be excluded in each tweet element. This view will be similar to the previous one, but showing data in a read only mode.

other_feed

User profile

When visiting /profile page (log in required), the logged in user's profile information must be displayed. The page will include a HTML form containing the current personal data, which will also be used to update any field if needed.

Both successful and failed form posts must redirect back to the same profile page, displaying proper response messages.

profile

Extra points

To make this application even more similar to the real Twitter service, we should expand the data model to support following between users.

Aside from extra tables and relationships in the database, part of the app logic should be modified. For example, in a user's feed we should display all tweets from people he is following, and not only his own tweets.

Re tweeting would also be a plus.

pyp-w4-gw-twitter-clone's People

Contributors

phillipdwright avatar martinzugnoni avatar santiagobasulto avatar

Watchers

James Cloos avatar  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.