Skip to content

Deployed django project that uses react as a front-end. Saves your URLs and gives a GUI Represetnation. Something like browser bookmarks.

Notifications You must be signed in to change notification settings

Greece4ever/PX-Scraper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PX-Scraper

This is the development source code that references this deployed website

The whole project relies on the file scraper.py witch makes use of python's HTTP Requests and bs4 modules scraping a specified domain an then returns a JSON object response that looks like this

{
   "url":"https://www.youtube.com/watch?v=dQw4w9WgXcQ",
   "title":"Rick Astley - Never Gonna Give You Up (Video)",
   "description":"Rick Astley's official music video for “Never Gonna Give You Up” Listen to Rick Astley: https://RickAstley.lnk.to/_listenYD Subscribe to the official Rick As...",
   "site_name":"YouTube",
   "image":"https://i.ytimg.com/vi/dQw4w9WgXcQ/maxresdefault.jpg",
   "keywords":[
      "the boys soundtrack",
      " the boys amazon prime",
      " Never gonna give you up the boys",
      " RickAstleyvevo",
      " vevo",
      " official",
      " Rick Roll",
      " video",
      " music video",
      " Rick Astley albu..."
   ],
   "domain":"WWW.YOUTUBE.COM"
}

Then the React-Front-End gets this object and with some JS and CSS magic it turns it to this

Hello

Integration

The only files needed for the production build (and the simple integration) are those inside build which can be generated by running

This will most likely run on all existing versions of django but I know that it 100% works on Django 3.0.8

In your React APP

yarn run build

or with npm

npm run build

This will Generate a file structure that will look like this

 - asset-manifest.json
 - index.html
 - logo192.png
 - logo512.png
 - manifest.json
 - precache-manifest.(hasnumbers).js
 - robots.txt
 - service-worker.js
 - static

To connect this with Django

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            #Here put the root 'build' directory that was generated to look for html files (templates) 
            os.path.join(BASE_DIR,"frontend/build")
        ],
       ...
    },
]

and also for the CSS and JS files

STATICFILES_DIRS = [
    #Directory to look for static files 
    os.path.join(BASE_DIR,"frontend/build/static")
]

Now to configure the routing in the main projcet's urls.py

from django.urls import path,re_path

urlpatterns = [
    #Any URLS you have here plus these
    ....
    #This is the index.html file in build

    path('',TemplateView.as_view(template_name="index.html")),
    #If you use React-Routing and want to handle all other urls by react-router you put this here (Any urls configured before will be handled by django)
    re_path(r'^(?:.*)/?$',TemplateView.as_view(template_name="index.html"))
]  

and this is it for the React-Django integration, you only need the build folder for the front-end and the urls.py and settings.py configurations

This is fully suitable for the production build and you will not need to change anything in order to get react and django to work

About

Deployed django project that uses react as a front-end. Saves your URLs and gives a GUI Represetnation. Something like browser bookmarks.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published