Is it possible to upload a simple html and javascript file structure to heroku?

前端 未结 10 1458
逝去的感伤
逝去的感伤 2020-12-04 06:25

I\'m trying to deploy an open source project of mine to heroku, it is by necessity very simple with just static html and javascript. But do they not support static sites?

相关标签:
10条回答
  • 2020-12-04 06:59

    Here is a more elegant method: Just add a file called package.json which tells Heroku to use harp as your server:

    {
      "name": "my-static-site",
      "version": "1.0.0",
      "description": "This will load any static html site",
      "scripts": {
        "start": "harp server --port $PORT"
      },
      "dependencies": {
        "harp": "*"
      }
    }
    

    and then deploy to Heroku. Done!

    Further information: https://harpjs.com/docs/deployment/heroku

    0 讨论(0)
  • 2020-12-04 07:00

    Here is what worked for me:

    cd myProject 
    git init
    heroku create myApp 
    heroku git:remote -a myApp 
    

    If the entry point is main.html, create index.php with this single line of content:

    <?php include_once("main.html"); ?>
    

    and then perform the following steps:

    echo '{}' > composer.json 
    git add . 
    git commit -am "first commit" 
    git push heroku master
    

    Go to http://myApp.herokuapp.com/ and your app should be online now.

    0 讨论(0)
  • 2020-12-04 07:01

    You can use rack to do this:

    https://devcenter.heroku.com/articles/static-sites-on-heroku

    or you can use something like Octopress/Jekyll who uses sinatra.

    But you need a minimum stack to serve html static content

    0 讨论(0)
  • 2020-12-04 07:01

    I know this might be a little old but I ended up using Vienna Gemw to deploy this, basically its a small Rack application that will let you serve everything in your public folder (css, images, js, html) with just a couple of lines of Ruby:

    require 'vienna'
    run Vienna
    

    Also, for deploying this on heroku you need to create a Gemfile:

    source 'https://rubygems.org'
    gem 'rack'
    gem 'vienna'
    

    Then run bundle install, in case you don't have the bundle gem installed just run on your terminal:

    sudo gem install bundle
    

    And thats pretty much of it, you can have more information on: http://kmikael.com/2013/05/28/creating-static-sites-in-ruby-with-rack/

    0 讨论(0)
提交回复
热议问题