Integrating Ember CLI with Django app - python

Before Ember CLI, I use to create an index.html page within Django project, plus the App.js file and all seemed to be working great.
Now that Ember is using CLI, it seems that there is no easy way to integrate Ember CLI project within Django application.
So I read that people are recommending using Ember CLI to develop the front-end, and Django to develop the REST API. However deployment is not easy, because you need to copy the Ember dist folder under Django static folder, plus change all the static asset url under Ember app to point to Django static path.
So it seems that, there is no easy way to integrate the two into one single development process.
Do you guys, have any suggestions on how to integrate the development, and deployment process?
Thx.

For projects like this, you should use separate repositories for your server app and client app(s).
Consider a project that has 4 code repositories, 1 server and 3 clients:
myproject (A Django app written in Python that provides an API for clients)
myproject-web (The Ember.js web client written in JavaScript)
myproject-ios (An iOS client app written in Swift)
myproject-android (An Android client app written in Java)
The core app will be deployed to a server that is capable of hosting Python apps (e.g. uWSGI).
Because the Ember.js project is ultimately a static resource, you can serve it from pretty much anywhere (e.g. NGINX), and point it at a separate API server that hosts the Django project (e.g. https://app.myproject.com/api/). See documentation on configuring ember-django-adapter to use a custom API host: http://dustinfarris.com/ember-django-adapter/configuring/
iOS of course would be deployed to the Apple App Store, and the Android project would be deployed to Google Play.
Each repository is a separate codebase with different requirements and deployment strategies—which is why it is best to keep them separate, so you can think about them and work with them in isolation. Just because Django can handle static assets doesn't mean you should rely on it—trying to host an Ember.js project (or any other JS framework project) within a Django project is just overcomplicating things. Hope that helps.

I am currently implementing a Ember-CLI app served by Django.
Here are the steps that I followed:
On Django:
Create a sub-project in your django project (ie: ember)
Install django-redis-views that will serve your index.html from redis.
Create a S3 bucket + CDN on AWS (or other storage product) in order to store your assets
On Ember:
install ember-deploy-redis & ember-deploy-s3
Add credentials to config.deployment and correct fingerprint in your ember-cli-build.js
Deploy ember
Useful link:
Easy deployment using redis + CDN: http://ember-cli.github.io/ember-cli-deploy/
Pip package that help your retrieving your index.html stored on redis: https://github.com/kevinlondon/django-redis-views

Related

How and where do I deploy a Flask + React web app?

I am building a web app with a Flask backend and a React front end, and I would now like to deploy it, buy a domain, and set it up. What is the easiest way to do this?
Here's my research:
This website shows how to deploy an app on Heroku. I did this, but Heroku seems to be unavailable a lot, at least today.
This blog post seems to suggest I could create a GCE instance and run things there, though (i) it seems like a little more configuration that I'd like (ii) I would need a way to link the nginx server to my domain. I suppose the benefit is that the two apps run on the same machine?
This SO post had OP redo his work and it somehow worked. I'm not sure how to deploy Docker apps online, though.
Is there an easy way to deploy to a reliable service (Google Cloud/AWS/Azure)? My code has the following structure:
build/ # Result of `yarn build`
server/
server.py # Flask server
src/ # React code
Component/
Component.js
Component.sass
index.css
index.js
...
public/
index.html
# Images and other stuff.
I figured out how to do this using Azure. I created an App Service, then installed the Azure Tools VS Code extension. You need to move the Python server to the root directory and rename it to app.py (so the .env is also in the root folder), and then you can right-click your App Service in VS Code (in the Azure Tools tab) and then click Deploy to Web App. Easy!

Deploying React - django apps on Azure web apps

Locally, I am able to run my django app and react app.
I migrated the django app to the azure web apps.
My question is, what is best practice regarding connecting the react app to the django app. Should I start another web app instance, or should I try to run both on the same instance?
The easiest way is that both React and Django are deployed on the same instance, however it depends on your need.
There are many ways to deploy Django + React, I will mentioned only two:
Simple one: Just import react libraries into your Django template and deploy your Django on the instance as a normal Django project. You may refer to this tutorial on how to accomplish this: Add React to Django Template
Second way which I would recommend: Deploy Django and React separately. Django app to be deployed on the Azure instance and react to be deployed as a static website on Azure Blob storage (You may refer to this tutorial: Host React on Azure Blob). In this case, your react app will be using the Django exposed APIs (through Django DRF). You may refer to this tutorial for further details: Deploy React + Django

Can we manage the deployment of each django app within a single Django project independently?

Lets say we have one django project that has two apps - FooApp & BarApp.
Each app talks to its own database. Meaning they both manage their own set of models. Is it possible to manage the deployments of these apps independently? It's okay for them to be deployed on same server within the same nginx process as long as I am able to make changes to the apps without bringing down the other as well.
I understand that these can very well be separate projects and they can communicate with each other using RESTful APIs. For my needs, I want to avoid that REST interaction for the time being.
The django documentation [here][1] describes a django project and django app as follows
Django project:
The term project describes a Django web application.
Django App:
The term application describes a Python package that provides some set
of features.
So if the app is simply a python package, and the django project is really the one that defines how these apps are managed via the settings module, then I suppose there is no straight forward way of accomplishing what I want. Or is there anything I can do?
TIA
[1]: https://docs.djangoproject.com/en/dev/ref/applications/

Deploy django application on Microsoft Azure or Amazon Elastic Besanstalk

I'm deploying a django (python) application. I wondered what is the best way to deploy it. With microsoft azure or Amazon Elastic Beanstalk ?
The application just needs to view data from a database. What are (dis)advantages of azure or elastic beanstalk?
I'm using OSX 10.9.5 and Python 3.4.3
As Gaurav Mantri said, you need to provide more details - atleast the OS you are using. Some more surfing could lead you here :
What's the recommended way to deploy a Django app on IIS?
For web apps, Azure has Azure App Service. Deployment can be done through a variety of ways, including FTP, git, or from Visual Studio. Since you're using Mac, I would recommend deploying via git.
To do so, first create a web app in the Azure portal, and then follow the steps here:
https://azure.microsoft.com/en-us/documentation/articles/web-sites-publish-source-control/
The advantages of Azure App Service, is that you can easily scale your app to many machines, and everything is taken care for you. Note that depending on how you've configured your database, you would have to deploy that separately.
Also, if you want to test Azure App Service, you can easily create a small sample Django application, using the Azure gallery. See the screen shot below.
Azure Web Apps provide a volume of ways for deployment your web applications. We can leverage tools/IDEs including FTP tools , Visual Studio and WebMatrix on Windows for remoting and modifying your web site code, and leverage repository for continuous deployment including local GIT, GITHUB, Visual Studio Online, Dropbox, Bitbucket.
It depends which way you prefer to.
As # theadriangreen mentioned, Azure Web Apps provide Django template for a quick start, you can simply create a Django application and pull the code to local leveraging the methods above.
Beside Continuous deployment using GIT in Azure App Service, you also can refer to Creating web apps with Django in Azure for more information.

How to deploy Flask Web app in Production server from PyCharm

I am new to Flask Web with Python. I developed a simple Flask with Pycharm. Now I want to deploy it on my college server. I remember when I develop php web app I used to copy it to www folder in var and run it from there.
Can someone explain me how do I deploy python web app in Linux production server.
First, you need to figure out what your server provides from its sysadmin. There are tens of ways to do this, and all of them have different answers.
Given that you have used php on the system before, I'll assume you are using Apache httpd.
First, you would need to have a wsgi provider installed (e.g. mod_wsgi) , and then wire your application into the wsgi provider.
See the mod_wsgi page and flask docs for more information on how to precisely do this.
https://code.google.com/p/modwsgi/
http://flask.pocoo.org/docs/0.10/deploying/
Another option is to have python bring its own webserver and optionally have a proxy redirect / load balance.

Categories

Resources