Coder Social home page Coder Social logo

csassignment's Introduction

1)Setting up the database

I have used postgresql as db, tables can be created via running db_script.py or by below SQL Queries Note: i) uuid extension must be enabled for creating cs_tweet table, can install via command: CREATE EXTENSION "uuid-ossp"; ii)to create via python script, asyncio supported python version has to be present as we have used asyncpg driver and for actual project used sync driver psycopg2.

CREATE TABLE cs_user ( user_id SERIAL NOT NULL, user_name VARCHAR(10) NOT NULL, created_timestamp TIMESTAMP WITHOUT TIME ZONE DEFAULT now(), PRIMARY KEY (user_id), UNIQUE (user_name) )

CREATE TABLE cs_tweet ( tweet_id UUID DEFAULT uuid_generate_v4() NOT NULL, tweet VARCHAR(140) NOT NULL, created_timestamp TIMESTAMP WITHOUT TIME ZONE DEFAULT now(), user_id INTEGER NOT NULL, PRIMARY KEY (tweet_id), FOREIGN KEY(user_id) REFERENCES cs_user (user_id) )

2)Hosted the backend & db on below host

Url: https://madhavcs.centralus.cloudapp.azure.com

Routes: i)Create user curl -XPOST -H "Content-type: application/json" -d '{"user_name" : "madhav1234"}' 'https://madhavcs.centralus.cloudapp.azure.com/user'

ii)Create tweet curl -XPOST -H 'Authorization:Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJtYWRoYTEyMzQiLCJleHAiOjE2NDM1NTE0NjIsImlhdCI6MTY0MzU0Nzg2Mn0.-6eLK72tqyEbuC29UNkd0sEe9aNvzNi6rnDoQme3las' -H "Content-type: application/json" -d '{"user_id" : 4, "tweet" : "hello" }' 'https://madhavcs.centralus.cloudapp.azure.com/tweet'

iii)list tweets from particular date curl -XGET -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJtYWRoYTEyMzQiLCJleHAiOjE2NDM1NTE0NjIsImlhdCI6MTY0MzU0Nzg2Mn0.-6eLK72tqyEbuC29UNkd0sEe9aNvzNi6rnDoQme3las' -H "Content-type: application/json" 'https://madhavcs.centralus.cloudapp.azure.com/tweets?date=01-01-2022&user_name=madhav1234'

iv)Delete tweets for a user curl -XDELETE -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJtYWRoYTEyMzQiLCJleHAiOjE2NDM1NTE0NjIsImlhdCI6MTY0MzU0Nzg2Mn0.-6eLK72tqyEbuC29UNkd0sEe9aNvzNi6rnDoQme3las' -H "Content-type: application/json" 'https://madhavcs.centralus.cloudapp.azure.com/tweets/madhav1234'

csassignment's People

Contributors

zipzapper113 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.