How can I edit python files in heroku? - heroku

I am using Heroku to run a Python telegram bot with Heroku Postgres as DB. I wanted to edit a Python file in my app so how can I do it? Is there any live text editor I can use to edit my file?
Thanks.

You need to have git installed on your CLI.
Clone the git repo from GitHub (the following git url is just an example)
git clone https://github.com/NNTin/discord-twitter-bot.git
Go to Heroku settings. There you will find a Heroku git URL. Add the Heroku remote.
git remote add heroku https://git.heroku.com/[yourappname].git
Do your code changes with your editor of choice. Version and commit your changes
git add .
git commit -m "a helpful commit message to know what you have done in the past"
Push the changes to your heroku remote
git push heroku master

Related

Heroku clone creates an empty folder

So I am trying to learn heroku and yesterday from another computer I created an app. Today, from a different computer I am trying to clone the app (download the code) and keep working on the same app so I did this
heroku git:clone -a myappname
I get the message
warning you have appeared to have cloned an empty directory
The app is running online so the code must be there.
According to the documentation this command does this
This will create a new directory named after your app with its source
and complete repository history, as well as adding a heroku git remote
to facilitate further updates.
However, the repository is empty.
I saw the question below but I that didn't work for me. How can I simply get the code locally and keep working on this app without creating a new one? Thanks.
Why am I getting an empty repo when cloning my keystone app to local repo from heroku?
This is counterintuitive, but looks like it is by design at Heroku. You don't copy from Heroku git to local drive, but the other way around - from your PC to Heroku.
You need to create or clone a repository on your local PC.
git create <new repository> OR
git clone <source>
then init your repository and commit code:
$ cd myapp
$ git init
Initialized empty Git repository in .git/
$ git add .
$ git commit -m "my first commit"
Then you need to link your repository with Heroku. Download their Toolbelt and run:
heroku git:remote -a your_app_name_on_heroku
And deploy code:
git push heroku master
Hope that helps. I had to open a ticket at Heroku to figure this out. Check Heroku Git instructions for further reference.

Deploy Parse-Server

I deployed Parse-Server-exemple to Heroku using thee Deploy button, and everything is working fine. (up to the fact that there are some bugs)
But the Parse-Server(https://github.com/ParsePlatform/parse-server)is being updated more frequently and now has lower bugs.
How to deploy Parse-Server on Heroku ?? or at least how to update the server running on my existing Heroku app ?? I can't find the answer anywhere
Parse-server is the nodejs package. you can remove this line here and you can remove the node_modules from .gitignore, then you need to download the "Parse Server" to your node_modles folder and deploy it. but it will be easy if you try to use some service like www.parseground.com
Your starting point should be reading up on how to deploy nodejs apps on heroku. Parse Server is just another npm module. Contrary to #pivanov's answer you should preferably keep node_modules in gitignore and let heroku install the npm packages including Parse Server. This is what heroku recommends in their documentation.
You can clone your parse-apps by running the falling command using the heroku work belt
$ heroku login
$ heroku git:clone -a
Heroku at this point automatically create a git branch 'master' that you can commit to.
You can now make changes to your parse server version depending in the available version.
Current version i think is 2.1.4
"parse-server": "^2.1.4",
You can now commit and push changes to the master branch created.
$ git add .
$ git commit -am "make it better"
$ git push heroku master
You can use
npm update
it will update the parse server if you have used "*" as its version in your package.json file.

'heroku' does not appear to be a git repository

When I try to push my app to Heroku I get this response:
fatal: 'heroku' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I have tried 'heroku keys:add' but still comes up with the same result.
I already have an ssh key for my GitHub account.
To add a Heroku app as a Git remote, you need to execute heroku git:remote -a yourapp.
Source: Deploying with Git
You could try the following in your root directory:
// initialize git for your project, add the changes and perform a commit
git init
git add .
git commit -m "first commit"
// create heroku app and push to heroku
heroku create
git push heroku master
Not sure where you are in the process. You also don't need github to deploy on heroku, just git. Hope this helps!
First, make sure you're logged into heroku:
heroku login
Enter your credentials.
It's common to get this error when using a cloned git repo onto a new machine. Even if your heroku credentials are already on the machine, there is no link between the cloned repo and heroku locally yet. To do this, cd into the root dir of the cloned repo and run
heroku git:remote -a yourapp
Following official Heroku article:
Initialize GIT
$ cd myapp
$ git init
$ git add .
$ git commit -m "my first commit"
Then create (initialize) heroku app with:
$ heroku create YourAppName
Lastly add git remote:
$ heroku git:remote -a YourAppName
Now you can safely deploy your app with:
$ git push heroku master
You should wait for some time and see if you don't get any error/interrupt on console while deploying. For details look at heroku article.
heroku git:remote -a YourAppName
You forgot to link your app name to your heroku. It's a very common mistake.
if your app is not created, then use:
heroku create (optional app name)
else:
git add .
git commit -m "heroku commit"
heroku git:remote -a YOUR_APP_NAME
git push heroku master
Follow this steps:
$ heroku login
Create a new Git repository
Initialize a git repository in a new or existing directory
$ cd my-project/
$ git init
$ heroku git:remote -a appname
Deploy your application
Commit your code to the repository and deploy it to Heroku using Git.
$ git add .
$ git commit -am "make it better"
$ git push heroku master
Existing Git repository
For existing repositories, simply add the heroku remote
$ heroku git:remote -a appname
Might be worth checking the config file in the .git folder. If the heroku parameters are missing then you´ll get this error heroku param
[remote "heroku"]
url = git#heroku.com:`[Your heroku app].git
fetch = +refs/heads/*:refs/remotes/heroku/*
the .git folder should be in the local computer file directory for the app you created in heroku. e.g C:\Users\You\Your app.git
Hope this helps
My problem was that I used git (instead of heroku git) to clone the app. Then I had to:
git remote add heroku git#heroku.com:MyApp.git
Remember to change MyApp to your app name.
Then I could proceed:
git push heroku master
If this error pops up, its because there is no remote named Heroku. When you do a Heroku create, if the git remote doesn’t already exist, we automatically create one (assuming you are in a git repo). To view your remotes type in:
“git remote -v”. # For an app called ‘appname’ you will see the following:
$ git remote -v
heroku git#heroku.com:appname.git (fetch)
heroku git#heroku.com:appname.git (push)
If you see a remote for your app, you can just “git push master” and replace with the actual remote name.
If it’s missing, you can add the remote with the following command:
git remote add heroku git#heroku.com:appname.git
If you’ve already added a remote called Heroku, you may get an error like this:
fatal: remote heroku already exists.
so, then remove the existing remote and add it again with the above command:
git remote rm heroku
Hope this helps…
show all apps heroku have access with
heroku apps
And check you app exist
then
execute heroku git:remote -a yourapp_exist
For me the answer was to cd into the root directory of the app before running heroku create or git push heroku master
Type heroku create
then git push heroku master (this is after creating a repository with 'git init' and committing the project)
I encountered the same error making a much more novice mistake: I was typing in Heroku with a capital "H," instead of lowercase.
I recognize that's certainly not the solution for everyone who encounters this error, but it was in my case.
I got the same error and it turned out I was in the wrong directory. It's a simple mistake to make so double check that you are in the root and then run heroku create and heroku git push master again. Of course you must have done git init, as mentioned in StickMaNX answer above, already before the heroku steps.
Run this
heroku create
before pushing your code.
I had the same issue, but later I found out that I forgot to create an app before deploying it. Try the following steps in terminal.
heroku login
heroku create
I am just learning heroku and often forget the steps so I wrote an article about it. You can find it here: https://medium.com/#saurav.panthee/deploy-flask-app-to-heroku-under-3-minutes-2ec1c0bc403a
I've seen all the answers here and the only thing missing is after going through these steps:
$ git add .
$ git commit -m "first heroku commit"
You should run the command below:
$ heroku git:remote -a <YourAppNameOnHeroku>
And lastly, run this:
$ git push -f heroku <NameOfBranch>:master
Notice I used <NameOfBranch> because if you're currently in a different branch to master it would still throw errors, so If you are working in master use master, else put the name of the branch there.
On the site:
https://dashboard.heroku.com/apps/**<YourAppNameOnHeroku>**/deploy/heroku-git
steps are described.
For those who are trying to get heroku to work on codeanywhere IDE:
heroku login
git remote add heroku git#heroku.com:MyApp.git
git push heroku
I had to run the Windows Command Prompt with Administrator privileges
The following commands will work well for ruby on rails application deployment on heroku if heroku is already installed on developers machine. # indicates a comment
heroku login
heroku create
heroku keys:add #this adds local machines keys to heroku so as to
avoid repeated password entry
git push heroku master
heroku rename new-application-name #rename application to the
preferred name other than the auto generated heroku name
In my case, I was already logged-in and I just executed git push.
i forgot to create a domain name before running git push heroku main. Creating a domain name resolved the problem.
First you have to install Heroku for CLI to be recognized
npm install -g heroku
npm command requires installation of node.js
Here you may download node.js: https://nodejs.org/en/download/
Then you have to login for authentication
heroku login
If you don't have an existing heroku repo
heroku create
Otherwise if you have an existing heroku repo
git remote add heroku git#heroku.com:<your app>.git
Then you may proceed pushing
git push heroku main

how to get rails app working locally after heroku clone?

My local code got messed up so I would like to download the version off heroku and start using that. I ran this to download
heroku git:clone -a myapp
then I installed taps using
gem install taps
then I ran
heroku db:pull
Is this all that's required? Just want to make sure that I don't mess up anything and can easily redeploy using git push heroku master later.
I haven't tried to pull code directly from Heroku, but I'm not sure why you would need to, since "git push heroku master" just pushes the master branch of your code from your Git repository to Heroku. Unless you've pushed your "dirty" code to Git, you should just be able to remove the bad code locally and do a "git pull" to get the good code from your Git repository directly.

How to upload a .php file to Heroku

I need to upload a .php file to my Heroku site.
How is this done using Terminal? I'm logged in vis Terminal and can see my app etc...
thanks for any help
If you need to upload a file on your Heroku app through the terminal, you need to track it and commit it with Git.
Install and configure the heroku toolbelt if not already done: https://devcenter.heroku.com/articles/quickstart
And then just create your app, start tracking your files and push them to heroku:
heroku create myapp
git init
git add .
git commit -m 'Initial commit'
git push heroku master

Resources