Flask landing page with Shopify web store - python

Is it possible to have a website where the landing page is a Flask app hosted through Heroku, connected to an online store that is hosted through Shopify?
For example, website.com is my Flask landing page. Then shop.website.com is a Shopify store selling my products.
If possible, what do I need to do?

Yes that's possible, but has nothing to do with Flask.
You can set your A record of website.com to point to your Heroku server.
For the Shopify part, I am not familiar with how exactly you set this up on their site, but they have a documentation where you can learn how to set up a subdomain (e.g. shop.website.com) to use with your Shopify shop.

Related

Restricted login from WordPress main site to Django web app

I am looking to integrate a wordpress website at mydomain.com with a django web app set up at analytics.mydomain.com. The wordpress website is the main website, where payments are accepted, a user area are that contains the link to the Django analytics tools. The Django app is hosted on another site (e.g Heroku) but is set up as a subdomain.
I would like the database and user authentication and information on WordPress to act as a master to the Django slave rather than vice versa.
How can I integrate authenticated users on the wordpress site, who have paid for analytics functionality, to have access to the django app without requiring login in again, or how can I share the user logins automatically - like an single sign on or something similar?
What is the best way to go about this?

How can I do Server Side Rendering of reactJS app with Python/Django as backend?

I have created the reactjs app using create-react-app and have used react-route-dom for routing. I have used Python/Django Rest Framework for the backend.I have used this tutorial to connect React with Django-
https://www.techiediaries.com/create-react-app-django/
Now I am facing issues like I can't post every page with the different previews and titles on social media platforms. Also, I have read the CSR(Client Side Rendering) is not good for SEO.
I think it would be better for you to create small NodeJS/Express server just as a web server for your React app. It will live separately on your REST API for which you can keep Phyton.
If I may recommend create-react-app is perfect for client side apps, but try to look into Next.js for server side rendered apps.

django-allauth with multiple domains

I am creating a web application that will support several domains. For example, if my app were named www.webapp.com, I'd also have numerous customers mapping their domains to my site via DNS CNAME mappings, i.e. webapp.yourdomain.com CNAME www.webapp.com and foo.anotherdomain.com CNAME www.webapp.com, etc...
I want users to authenticate against my app via Google or Facebook (OAuth 2.0) - without me (or the domain owners) having to create a separate Google/Facebook app per mapped domain. Ideally, I would have the base domain act as a broker and redirect to the appropriate mapped domain when responding to the callback url. For example, a user visiting webapp.yourdomain.com/accounts/facebook/login would authenticate against Facebook with a callback url going to www.webapp.com/accounts/facebook/login/callback. When processing the request, I could find the appropriate context, and redirect to webapp.yourdomain.com/accounts/facebook/login/callback where the real authentication would take place (and domain-specific auth cookies would be set).
So, is this doable in django-allauth? How much hacking would it require? Or, is there another social authentication solution for Django that would be easier to implement this in?
You should use Django sites framework together with django-allauth.
Consumer keys, tokens make use of the Django sites framework. This is
especially helpful for larger multi-domain projects, but also allows
for for easy switching between a development (localhost) and
production setup without messing with your settings and database.
Just configure each social app in the admin backend.

maintaining user authentication if i have some web pages on mod_python and some on mod_wsgi

I have a web application written in raw python and hosted on apache using mod_python. I am building another web application which is django based and will be hosted on same server using mod_wsgi.
Now, the scenerio is such that user will login from the web page which is using mod_python and a link will send him to my application which will be using mod_wsgi. My question is how can I maintain session? I need the same authentication to work for my application.
Thanks in advance.
If you're using django with mod_wsgi and a raw python page which only serve a link to django application, you don't need to maintain session on both page. When user click on first link and reach the django application, just check session there.
Django have session_db which use memcache. More information can be found here:
Django Sessions
SSO across web applications is poorly supported. One thing you can look at is:
http://www.openfusion.com.au/labs/mod_auth_tkt/
What you can do is really going to depend though on what authentication database you are currently using in the mod_python application and how you are remembering that someone is logged in. If you can provide that information, may be able to suggest other things.
Conceptually: store a cookie using your raw python web page that you process in a "welcome" view or custom middleware class in Django, and insert them into the sessions db. This is basically what hungnv suggests.
The most ridiculous way to do this would be to figure out how Django deals with sessions and session cookies, insert the correct row into Django's session database from your raw python app, and then custom-set the session cookie using Django's auth functions.

Bottle and GAE authentication using Google Accounts

I'm currently developing a bottle app on GAE, and it's already got its own home-made authentication system. However, I would also like to permit access to some areas to application admins using Google Accounts. I'm looking at the documentation, but I'm not quite following it.
On the development server, hiting any _ah link sends me straight to the desired page, but on GAE, it gives me bottle's own 404 page. Can you point me to the right page where I can get started with this (preferably not the official docs which I'm having hard time with)?
NOTE: Forgot to mention it's a Python version of GAE.
_ah will work only on the development server. It's a part of appengine sdk which emulates the GAE. Coming to your point. If you want to use the google's account for admin functionalities. Then you should do something like this
from google.appengine.api import users
if users.is_current_user_admin():
Here admin refers to the appengine admin. if you want to simply use the google authentication
then you should use users.get_current_user() to get the current logged in user and implement your own logic.

Categories